/******/ (() => { // webpackBootstrap
/******/ 	"use strict";
/******/ 	var __webpack_modules__ = ([
/* 0 */,
/* 1 */
/***/ ((module) => {

module.exports = require("@nestjs/core");

/***/ }),
/* 2 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.UserClientModule = void 0;
const common_1 = __webpack_require__(3);
const user_client_controller_1 = __webpack_require__(4);
const user_client_service_1 = __webpack_require__(5);
const db_module_1 = __webpack_require__(6);
const configure_1 = __webpack_require__(29);
const cache_1 = __webpack_require__(46);
const user_module_1 = __webpack_require__(52);
const login_module_1 = __webpack_require__(59);
const schedule_module_1 = __webpack_require__(74);
const wechat_1 = __webpack_require__(61);
const db_service_1 = __webpack_require__(7);
const SYS_CONFIG_1 = __webpack_require__(77);
const recharge_module_1 = __webpack_require__(78);
const core_1 = __webpack_require__(1);
const auth_guard_1 = __webpack_require__(83);
const device_module_1 = __webpack_require__(84);
const test_module_1 = __webpack_require__(98);
const alicloud_1 = __webpack_require__(88);
const water_bills_module_1 = __webpack_require__(101);
const water_test_module_1 = __webpack_require__(104);
const sys_config_repository_module_1 = __webpack_require__(44);
let UserClientModule = class UserClientModule {
};
exports.UserClientModule = UserClientModule;
exports.UserClientModule = UserClientModule = __decorate([
    (0, common_1.Module)({
        imports: [
            configure_1.ConfigureModule.forRoot(),
            db_module_1.DbModule,
            cache_1.CacheModule,
            wechat_1.WechatModule.forRootAsync({
                inject: [db_service_1.DbService],
                useFactory: async (db) => {
                    const configs = await db.sysConfig.selectValues(SYS_CONFIG_1.SYS_CONFIG.wechat);
                    return { appid: configs[SYS_CONFIG_1.SYS_CONFIG.appid], secret: configs[SYS_CONFIG_1.SYS_CONFIG.secret], mchid: configs[SYS_CONFIG_1.SYS_CONFIG.mchid], v3Key: configs[SYS_CONFIG_1.SYS_CONFIG.v3Key], publicKey: configs[SYS_CONFIG_1.SYS_CONFIG.publicKey], privateKey: configs[SYS_CONFIG_1.SYS_CONFIG.privateKey], baseNotifyUrl: configs[SYS_CONFIG_1.SYS_CONFIG.baseNotifyUrl] };
                }
            }),
            alicloud_1.AlicloudModule.forRootAsync({
                inject: [configure_1.ConfigureService],
                useFactory: async (config) => {
                    return {
                        ...config.get('alicloud')
                    };
                },
            }),
            sys_config_repository_module_1.SysConfigRepositoryModule,
            user_module_1.UserModule, login_module_1.LoginModule, schedule_module_1.ScheduleModule, recharge_module_1.RechargeModule, device_module_1.DeviceModule, test_module_1.TestModule, water_bills_module_1.WaterBillsModule, water_test_module_1.WaterTestModule, wechat_1.WechatModule
        ],
        controllers: [user_client_controller_1.UserClientController],
        providers: [user_client_service_1.UserClientService, { provide: core_1.APP_GUARD, useClass: auth_guard_1.AuthGuard }],
    })
], UserClientModule);


/***/ }),
/* 3 */
/***/ ((module) => {

module.exports = require("@nestjs/common");

/***/ }),
/* 4 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var _a;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.UserClientController = void 0;
const common_1 = __webpack_require__(3);
const user_client_service_1 = __webpack_require__(5);
let UserClientController = class UserClientController {
    constructor(userClientService) {
        this.userClientService = userClientService;
    }
    getHello() {
        return this.userClientService.getHello();
    }
};
exports.UserClientController = UserClientController;
__decorate([
    (0, common_1.Get)(),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", []),
    __metadata("design:returntype", String)
], UserClientController.prototype, "getHello", null);
exports.UserClientController = UserClientController = __decorate([
    (0, common_1.Controller)(),
    __metadata("design:paramtypes", [typeof (_a = typeof user_client_service_1.UserClientService !== "undefined" && user_client_service_1.UserClientService) === "function" ? _a : Object])
], UserClientController);


/***/ }),
/* 5 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.UserClientService = void 0;
const common_1 = __webpack_require__(3);
let UserClientService = class UserClientService {
    getHello() {
        return 'Hello World!';
    }
};
exports.UserClientService = UserClientService;
exports.UserClientService = UserClientService = __decorate([
    (0, common_1.Injectable)()
], UserClientService);


/***/ }),
/* 6 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.DbModule = void 0;
const common_1 = __webpack_require__(3);
const db_service_1 = __webpack_require__(7);
const typeorm_1 = __webpack_require__(9);
const configure_1 = __webpack_require__(29);
const device_repository_module_1 = __webpack_require__(37);
const user_repository_module_1 = __webpack_require__(38);
const recharge_option_repository_module_1 = __webpack_require__(39);
const device_type_repository_module_1 = __webpack_require__(40);
const water_test_repository_module_1 = __webpack_require__(41);
const water_bills_repository_module_1 = __webpack_require__(42);
const clean_record_repository_module_1 = __webpack_require__(43);
const sys_config_repository_module_1 = __webpack_require__(44);
const recharge_order_repository_module_1 = __webpack_require__(45);
let DbModule = class DbModule {
};
exports.DbModule = DbModule;
exports.DbModule = DbModule = __decorate([
    (0, common_1.Global)(),
    (0, common_1.Module)({
        imports: [
            typeorm_1.TypeOrmModule.forRootAsync({
                imports: [configure_1.ConfigureModule],
                inject: [configure_1.ConfigureService],
                useFactory: (config) => {
                    return {
                        ...config.get('db')
                    };
                },
            }),
            sys_config_repository_module_1.SysConfigRepositoryModule,
            device_repository_module_1.DeviceRepositoryModule,
            device_type_repository_module_1.DeviceTypeRepositoryModule,
            user_repository_module_1.UserRepositoryModule,
            recharge_option_repository_module_1.RechargeOptionRepositoryModule,
            recharge_order_repository_module_1.RechargeOrderRepositoryModule,
            water_test_repository_module_1.WaterTestRepositoryModule,
            water_bills_repository_module_1.WaterBillsRepositoryModule,
            clean_record_repository_module_1.CleanRecordRepositoryModule,
        ],
        providers: [db_service_1.DbService],
        exports: [db_service_1.DbService]
    })
], DbModule);


/***/ }),
/* 7 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.DbService = void 0;
const clean_record_repository_service_1 = __webpack_require__(8);
const sys_config_repository_service_1 = __webpack_require__(13);
const device_repository_service_1 = __webpack_require__(15);
const device_type_repository_service_1 = __webpack_require__(17);
const recharge_option_repository_service_1 = __webpack_require__(19);
const recharge_order_repository_service_1 = __webpack_require__(21);
const user_repository_service_1 = __webpack_require__(23);
const water_bills_repository_service_1 = __webpack_require__(25);
const water_test_repository_service_1 = __webpack_require__(27);
const common_1 = __webpack_require__(3);
let DbService = class DbService {
    constructor(sysConfig, device, deviceType, user, rechargeOption, rechargeOrder, waterBills, waterTest, cleanRecord) {
        this.sysConfig = sysConfig;
        this.device = device;
        this.deviceType = deviceType;
        this.user = user;
        this.rechargeOption = rechargeOption;
        this.rechargeOrder = rechargeOrder;
        this.waterBills = waterBills;
        this.waterTest = waterTest;
        this.cleanRecord = cleanRecord;
    }
};
exports.DbService = DbService;
exports.DbService = DbService = __decorate([
    (0, common_1.Injectable)(),
    __metadata("design:paramtypes", [typeof (_a = typeof sys_config_repository_service_1.SysConfigRepositoryService !== "undefined" && sys_config_repository_service_1.SysConfigRepositoryService) === "function" ? _a : Object, typeof (_b = typeof device_repository_service_1.DeviceRepositoryService !== "undefined" && device_repository_service_1.DeviceRepositoryService) === "function" ? _b : Object, typeof (_c = typeof device_type_repository_service_1.DeviceTypeRepositoryService !== "undefined" && device_type_repository_service_1.DeviceTypeRepositoryService) === "function" ? _c : Object, typeof (_d = typeof user_repository_service_1.UserRepositoryService !== "undefined" && user_repository_service_1.UserRepositoryService) === "function" ? _d : Object, typeof (_e = typeof recharge_option_repository_service_1.RechargeOptionRepositoryService !== "undefined" && recharge_option_repository_service_1.RechargeOptionRepositoryService) === "function" ? _e : Object, typeof (_f = typeof recharge_order_repository_service_1.RechargeOrderRepositoryService !== "undefined" && recharge_order_repository_service_1.RechargeOrderRepositoryService) === "function" ? _f : Object, typeof (_g = typeof water_bills_repository_service_1.WaterBillsRepositoryService !== "undefined" && water_bills_repository_service_1.WaterBillsRepositoryService) === "function" ? _g : Object, typeof (_h = typeof water_test_repository_service_1.WaterTestRepositoryService !== "undefined" && water_test_repository_service_1.WaterTestRepositoryService) === "function" ? _h : Object, typeof (_j = typeof clean_record_repository_service_1.CleanRecordRepositoryService !== "undefined" && clean_record_repository_service_1.CleanRecordRepositoryService) === "function" ? _j : Object])
], DbService);


/***/ }),
/* 8 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
    return function (target, key) { decorator(target, key, paramIndex); }
};
var _a;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.CleanRecordRepositoryService = void 0;
const common_1 = __webpack_require__(3);
const typeorm_1 = __webpack_require__(9);
const typeorm_2 = __webpack_require__(10);
const base_service_1 = __webpack_require__(11);
const CleanRecord_1 = __webpack_require__(12);
let CleanRecordRepositoryService = class CleanRecordRepositoryService extends base_service_1.BaseService {
    constructor(repository) {
        super();
        this.repository = repository;
        this.primaryKey = 'id';
    }
};
exports.CleanRecordRepositoryService = CleanRecordRepositoryService;
exports.CleanRecordRepositoryService = CleanRecordRepositoryService = __decorate([
    (0, common_1.Injectable)(),
    __param(0, (0, typeorm_1.InjectRepository)(CleanRecord_1.CleanRecord)),
    __metadata("design:paramtypes", [typeof (_a = typeof typeorm_2.Repository !== "undefined" && typeorm_2.Repository) === "function" ? _a : Object])
], CleanRecordRepositoryService);


/***/ }),
/* 9 */
/***/ ((module) => {

module.exports = require("@nestjs/typeorm");

/***/ }),
/* 10 */
/***/ ((module) => {

module.exports = require("typeorm");

/***/ }),
/* 11 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.BaseService = void 0;
const common_1 = __webpack_require__(3);
let BaseService = class BaseService {
    getRepository() {
        return this.repository;
    }
    get aliasToOriginalFields() {
        if (!this.aliasToOriginalFieldsMap) {
            this.aliasToOriginalFieldsMap = {};
            this.repository.metadata.ownColumns.forEach(column => {
                this.aliasToOriginalFieldsMap[column.propertyName] = column.databaseName;
            });
        }
        return this.aliasToOriginalFieldsMap;
    }
    get metadata() {
        return this.repository.metadata;
    }
    get tableName() {
        return this.repository.metadata.tableName;
    }
    createQueryBuilder() {
        return this.repository.createQueryBuilder();
    }
    aliasToFields(fields) {
        const aliasToOriginalFieldsMap = this.aliasToOriginalFields;
        return fields.map((field) => `\`${aliasToOriginalFieldsMap[field]}\` as \`${field}\``).join(',');
    }
    createQueryRunner() {
        return this.dataSource.createQueryRunner();
    }
    query(query, parameters) {
        return this.repository.query(query, parameters);
    }
    async count(where) {
        let total = await this.repository.count({
            where: where
        });
        return total;
    }
    async pagination(pageNo, pageSize, where, select, order) {
        pageSize = Number(pageSize);
        return this.find(where, select, (Number(pageNo) - 1) * pageSize, pageSize, order);
    }
    findOne(where, select, order) {
        return this.repository.findOne({
            select: select,
            where: where,
            order: order
        });
    }
    find(where, select, skip, take, order) {
        let options = {};
        if (where) {
            options.where = where;
        }
        if (select) {
            options.select = select;
        }
        if (skip) {
            options.skip = skip;
        }
        if (take) {
            options.take = take;
        }
        if (order) {
            options.order = order;
        }
        return this.repository.find(options);
    }
    async value(where, field) {
        const res = await this.findOne(where, [field]);
        return res ? res[field] : undefined;
    }
    async isExistsByWhere(where) {
        let res = await this.findOne(where, [this.primaryKey]);
        return res ? true : false;
    }
    async save(data, options) {
        return this.repository.save(data, options);
    }
    async saveMany(data, options) {
        return this.repository.save(data, options);
    }
    async insert(data) {
        let result = null;
        try {
            let res = await this.repository.insert(data);
            if (res) {
                let generatedMaps = res.generatedMaps;
                if (generatedMaps && generatedMaps.length > 0) {
                    result = {
                        affectedRows: generatedMaps.length,
                        rows: generatedMaps
                    };
                }
            }
        }
        catch (error) {
            console.log(error);
        }
        return result;
    }
    async update(criteria, partialEntity) {
        try {
            let res = await this.repository.update(criteria, partialEntity);
            return res.affected;
        }
        catch (error) {
            console.log(error);
        }
        return 0;
    }
    async delete(criteria) {
        try {
            let res = await this.repository.delete(criteria);
            return res.affected;
        }
        catch (error) {
        }
        return 0;
    }
};
exports.BaseService = BaseService;
exports.BaseService = BaseService = __decorate([
    (0, common_1.Injectable)()
], BaseService);


/***/ }),
/* 12 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.CleanRecord = void 0;
const typeorm_1 = __webpack_require__(10);
let CleanRecord = class CleanRecord {
};
exports.CleanRecord = CleanRecord;
__decorate([
    (0, typeorm_1.PrimaryGeneratedColumn)({ type: "int", name: "id", unsigned: true }),
    __metadata("design:type", Number)
], CleanRecord.prototype, "id", void 0);
__decorate([
    (0, typeorm_1.Column)("int", { name: "user_id", unsigned: true, default: () => "'0'" }),
    __metadata("design:type", Number)
], CleanRecord.prototype, "userId", void 0);
__decorate([
    (0, typeorm_1.Column)("int", { name: "device_id", unsigned: true, default: () => "'0'" }),
    __metadata("design:type", Number)
], CleanRecord.prototype, "deviceId", void 0);
__decorate([
    (0, typeorm_1.Column)("tinyint", {
        name: "status",
        comment: "0：等待开启，1：检测中，2：检测失败",
        unsigned: true,
        default: () => "'0'",
    }),
    __metadata("design:type", Number)
], CleanRecord.prototype, "status", void 0);
__decorate([
    (0, typeorm_1.Column)("tinyint", {
        name: "err",
        comment: "",
        unsigned: true,
        default: () => "'0'",
    }),
    __metadata("design:type", Number)
], CleanRecord.prototype, "err", void 0);
__decorate([
    (0, typeorm_1.Column)("int", {
        name: "create_time",
        comment: "创建时间",
        unsigned: true,
        default: () => "'0'",
    }),
    __metadata("design:type", Number)
], CleanRecord.prototype, "createTime", void 0);
exports.CleanRecord = CleanRecord = __decorate([
    (0, typeorm_1.Index)("device_id", ["deviceId"], {}),
    (0, typeorm_1.Index)("user_id", ["userId"], {}),
    (0, typeorm_1.Entity)("clean_record", { schema: "bacsense_water" })
], CleanRecord);


/***/ }),
/* 13 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
    return function (target, key) { decorator(target, key, paramIndex); }
};
var _a;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.SysConfigRepositoryService = void 0;
const base_service_1 = __webpack_require__(11);
const common_1 = __webpack_require__(3);
const typeorm_1 = __webpack_require__(9);
const typeorm_2 = __webpack_require__(10);
const SysConfig_1 = __webpack_require__(14);
let SysConfigRepositoryService = class SysConfigRepositoryService extends base_service_1.BaseService {
    constructor(repository) {
        super();
        this.repository = repository;
        this.primaryKey = 'id';
    }
    async selectValues(code, ...fields) {
        const configs = {};
        if (fields.length > 0) {
            const arr = [];
            fields.forEach(field => {
                arr.push(`JSON_EXTRACT(config, CONCAT('$.', '${field}', '.value')) AS \`${field}\``);
            });
            const items = await this.query(`select ${arr.join(',')} from ${this.tableName} where code = '${code}'`);
            items.forEach(item => {
                for (let k in item) {
                    configs[k] = item[k];
                }
            });
        }
        else {
            const sysConfig = await this.findOne({ code: code });
            if (sysConfig != null) {
                for (let k in sysConfig.config) {
                    configs[k] = sysConfig.config[k].value;
                }
            }
        }
        return configs;
    }
    async selectValue(code, field) {
        const configs = await this.selectValues(code, field);
        return field in configs ? configs[field] : null;
    }
};
exports.SysConfigRepositoryService = SysConfigRepositoryService;
exports.SysConfigRepositoryService = SysConfigRepositoryService = __decorate([
    (0, common_1.Injectable)(),
    __param(0, (0, typeorm_1.InjectRepository)(SysConfig_1.SysConfig)),
    __metadata("design:paramtypes", [typeof (_a = typeof typeorm_2.Repository !== "undefined" && typeorm_2.Repository) === "function" ? _a : Object])
], SysConfigRepositoryService);


/***/ }),
/* 14 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.SysConfig = void 0;
const typeorm_1 = __webpack_require__(10);
let SysConfig = class SysConfig {
};
exports.SysConfig = SysConfig;
__decorate([
    (0, typeorm_1.PrimaryGeneratedColumn)({ type: "int", name: "id", unsigned: true }),
    __metadata("design:type", Number)
], SysConfig.prototype, "id", void 0);
__decorate([
    (0, typeorm_1.Column)("varchar", { name: "name", length: 50 }),
    __metadata("design:type", String)
], SysConfig.prototype, "name", void 0);
__decorate([
    (0, typeorm_1.Column)("varchar", { name: "code", length: 50, default: () => "'编码'" }),
    __metadata("design:type", String)
], SysConfig.prototype, "code", void 0);
__decorate([
    (0, typeorm_1.Column)("json", { name: "config", nullable: true, comment: "配置" }),
    __metadata("design:type", Object)
], SysConfig.prototype, "config", void 0);
exports.SysConfig = SysConfig = __decorate([
    (0, typeorm_1.Entity)("sys_config", { schema: "bacsense_water" })
], SysConfig);


/***/ }),
/* 15 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
    return function (target, key) { decorator(target, key, paramIndex); }
};
var _a;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.DeviceRepositoryService = void 0;
const common_1 = __webpack_require__(3);
const typeorm_1 = __webpack_require__(9);
const typeorm_2 = __webpack_require__(10);
const base_service_1 = __webpack_require__(11);
const Device_1 = __webpack_require__(16);
let DeviceRepositoryService = class DeviceRepositoryService extends base_service_1.BaseService {
    constructor(repository) {
        super();
        this.repository = repository;
        this.primaryKey = 'id';
    }
};
exports.DeviceRepositoryService = DeviceRepositoryService;
exports.DeviceRepositoryService = DeviceRepositoryService = __decorate([
    (0, common_1.Injectable)(),
    __param(0, (0, typeorm_1.InjectRepository)(Device_1.Device)),
    __metadata("design:paramtypes", [typeof (_a = typeof typeorm_2.Repository !== "undefined" && typeorm_2.Repository) === "function" ? _a : Object])
], DeviceRepositoryService);


/***/ }),
/* 16 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.Device = void 0;
const typeorm_1 = __webpack_require__(10);
let Device = class Device {
};
exports.Device = Device;
__decorate([
    (0, typeorm_1.PrimaryGeneratedColumn)({ type: "int", name: "id", unsigned: true }),
    __metadata("design:type", Number)
], Device.prototype, "id", void 0);
__decorate([
    (0, typeorm_1.Column)("varchar", { name: "name", length: 100 }),
    __metadata("design:type", String)
], Device.prototype, "name", void 0);
__decorate([
    (0, typeorm_1.Column)("int", {
        name: "device_type_id",
        comment: "类型",
        default: () => "'0'",
    }),
    __metadata("design:type", Number)
], Device.prototype, "deviceTypeId", void 0);
__decorate([
    (0, typeorm_1.Column)("int", {
        name: "total_water_usage",
        comment: "总用水量",
        unsigned: true,
        default: () => "'0'",
    }),
    __metadata("design:type", Number)
], Device.prototype, "totalWaterUsage", void 0);
__decorate([
    (0, typeorm_1.Column)("json", { name: "port_data", nullable: true, comment: "端口数据" }),
    __metadata("design:type", Object)
], Device.prototype, "portData", void 0);
__decorate([
    (0, typeorm_1.Column)("tinyint", {
        name: "connect_status",
        comment: "链接状态1：是，0：否",
        default: () => "'0'",
    }),
    __metadata("design:type", Number)
], Device.prototype, "connectStatus", void 0);
__decorate([
    (0, typeorm_1.Column)("int", {
        name: "online_time",
        comment: "上线时间",
        unsigned: true,
        default: () => "'0'",
    }),
    __metadata("design:type", Number)
], Device.prototype, "onlineTime", void 0);
__decorate([
    (0, typeorm_1.Column)("int", {
        name: "offline_time",
        comment: "离线时间",
        unsigned: true,
        default: () => "'0'",
    }),
    __metadata("design:type", Number)
], Device.prototype, "offlineTime", void 0);
__decorate([
    (0, typeorm_1.Column)("boolean", {
        name: "at_ali",
        comment: "是否已经注册到阿里云"
    }),
    __metadata("design:type", Boolean)
], Device.prototype, "atAli", void 0);
__decorate([
    (0, typeorm_1.Column)("char", { name: "ali_id", comment: "阿里云的设备id", length: 32 }),
    __metadata("design:type", String)
], Device.prototype, "aliId", void 0);
__decorate([
    (0, typeorm_1.Column)("char", {
        name: "ali_secret",
        comment: "阿里云的设备Secret",
        length: 32,
    }),
    __metadata("design:type", String)
], Device.prototype, "aliSecret", void 0);
__decorate([
    (0, typeorm_1.Column)("int", { name: "merchant_id", unsigned: true, default: () => "'0'" }),
    __metadata("design:type", Number)
], Device.prototype, "merchantId", void 0);
__decorate([
    (0, typeorm_1.Column)("int", {
        name: "station_id",
        comment: "站点id",
        unsigned: true,
        default: () => "'0'",
    }),
    __metadata("design:type", Number)
], Device.prototype, "stationId", void 0);
__decorate([
    (0, typeorm_1.Column)("int", { name: "user_id", unsigned: true, default: () => "'0'" }),
    __metadata("design:type", Number)
], Device.prototype, "userId", void 0);
__decorate([
    (0, typeorm_1.Column)("char", { name: "sim", comment: "物联网卡", length: 20 }),
    __metadata("design:type", String)
], Device.prototype, "sim", void 0);
__decorate([
    (0, typeorm_1.Column)("varchar", { name: "hardware", comment: "硬件", length: 30 }),
    __metadata("design:type", String)
], Device.prototype, "hardware", void 0);
__decorate([
    (0, typeorm_1.Column)("varchar", { name: "software", comment: "软件", length: 30 }),
    __metadata("design:type", String)
], Device.prototype, "software", void 0);
__decorate([
    (0, typeorm_1.Column)("tinyint", {
        name: "signal",
        comment: "信号强度",
        unsigned: true,
        default: () => "'0'",
    }),
    __metadata("design:type", Number)
], Device.prototype, "signal", void 0);
__decorate([
    (0, typeorm_1.Column)("varchar", { name: "remark", length: 100 }),
    __metadata("design:type", String)
], Device.prototype, "remark", void 0);
__decorate([
    (0, typeorm_1.Column)("boolean", {
        name: "is_private",
        comment: "1：私人的"
    }),
    __metadata("design:type", Boolean)
], Device.prototype, "isPrivate", void 0);
__decorate([
    (0, typeorm_1.Column)("boolean", { name: "enable" }),
    __metadata("design:type", Boolean)
], Device.prototype, "enable", void 0);
__decorate([
    (0, typeorm_1.Column)("int", {
        name: "creator_id",
        comment: "创建人",
        unsigned: true,
        default: () => "'0'",
    }),
    __metadata("design:type", Number)
], Device.prototype, "creatorId", void 0);
__decorate([
    (0, typeorm_1.Column)("int", { name: "create_time", unsigned: true, default: () => "'0'" }),
    __metadata("design:type", Number)
], Device.prototype, "createTime", void 0);
__decorate([
    (0, typeorm_1.Column)("int", { name: "update_time", unsigned: true, default: () => "'0'" }),
    __metadata("design:type", Number)
], Device.prototype, "updateTime", void 0);
exports.Device = Device = __decorate([
    (0, typeorm_1.Entity)("device", { schema: "charge" })
], Device);


/***/ }),
/* 17 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
    return function (target, key) { decorator(target, key, paramIndex); }
};
var _a;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.DeviceTypeRepositoryService = void 0;
const common_1 = __webpack_require__(3);
const typeorm_1 = __webpack_require__(9);
const typeorm_2 = __webpack_require__(10);
const base_service_1 = __webpack_require__(11);
const DeviceType_1 = __webpack_require__(18);
let DeviceTypeRepositoryService = class DeviceTypeRepositoryService extends base_service_1.BaseService {
    constructor(repository) {
        super();
        this.repository = repository;
        this.primaryKey = 'id';
    }
};
exports.DeviceTypeRepositoryService = DeviceTypeRepositoryService;
exports.DeviceTypeRepositoryService = DeviceTypeRepositoryService = __decorate([
    (0, common_1.Injectable)(),
    __param(0, (0, typeorm_1.InjectRepository)(DeviceType_1.DeviceType)),
    __metadata("design:paramtypes", [typeof (_a = typeof typeorm_2.Repository !== "undefined" && typeorm_2.Repository) === "function" ? _a : Object])
], DeviceTypeRepositoryService);


/***/ }),
/* 18 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.DeviceType = void 0;
const typeorm_1 = __webpack_require__(10);
let DeviceType = class DeviceType {
};
exports.DeviceType = DeviceType;
__decorate([
    (0, typeorm_1.PrimaryGeneratedColumn)({ type: "int", name: "id", unsigned: true }),
    __metadata("design:type", Number)
], DeviceType.prototype, "id", void 0);
__decorate([
    (0, typeorm_1.Column)("varchar", { name: "name", length: 30 }),
    __metadata("design:type", String)
], DeviceType.prototype, "name", void 0);
__decorate([
    (0, typeorm_1.Column)("tinyint", {
        name: "port_count",
        comment: "端口数",
        unsigned: true,
        default: () => "'0'",
    }),
    __metadata("design:type", Number)
], DeviceType.prototype, "portCount", void 0);
__decorate([
    (0, typeorm_1.Column)("int", { name: "parent_id", default: () => "'0'" }),
    __metadata("design:type", Number)
], DeviceType.prototype, "parentId", void 0);
__decorate([
    (0, typeorm_1.Column)("int", {
        name: "top_id",
        comment: "最顶级id",
        unsigned: true,
        default: () => "'0'",
    }),
    __metadata("design:type", Number)
], DeviceType.prototype, "topId", void 0);
__decorate([
    (0, typeorm_1.Column)("varchar", { name: "code", length: 20 }),
    __metadata("design:type", String)
], DeviceType.prototype, "code", void 0);
__decorate([
    (0, typeorm_1.Column)("int", { name: "level", unsigned: true, default: () => "'0'" }),
    __metadata("design:type", Number)
], DeviceType.prototype, "level", void 0);
__decorate([
    (0, typeorm_1.Column)("varchar", { name: "ali_product", comment: "阿里云产品", length: 15 }),
    __metadata("design:type", String)
], DeviceType.prototype, "aliProduct", void 0);
__decorate([
    (0, typeorm_1.Column)("json", { name: "param_fields", nullable: true, comment: "参数字段" }),
    __metadata("design:type", Array)
], DeviceType.prototype, "paramFields", void 0);
__decorate([
    (0, typeorm_1.Column)("boolean", { name: "enable" }),
    __metadata("design:type", Boolean)
], DeviceType.prototype, "enable", void 0);
__decorate([
    (0, typeorm_1.Column)("int", {
        name: "sort",
        comment: "排序越大越靠前",
        default: () => "'0'",
    }),
    __metadata("design:type", Number)
], DeviceType.prototype, "sort", void 0);
__decorate([
    (0, typeorm_1.Column)("int", {
        name: "creator_id",
        comment: "创建人",
        unsigned: true,
        default: () => "'0'",
    }),
    __metadata("design:type", Number)
], DeviceType.prototype, "creatorId", void 0);
__decorate([
    (0, typeorm_1.Column)("int", { name: "create_time", default: () => "'0'" }),
    __metadata("design:type", Number)
], DeviceType.prototype, "createTime", void 0);
__decorate([
    (0, typeorm_1.Column)("int", { name: "update_time", default: () => "'0'" }),
    __metadata("design:type", Number)
], DeviceType.prototype, "updateTime", void 0);
exports.DeviceType = DeviceType = __decorate([
    (0, typeorm_1.Entity)("device_type", { schema: "charge" })
], DeviceType);


/***/ }),
/* 19 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
    return function (target, key) { decorator(target, key, paramIndex); }
};
var _a;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.RechargeOptionRepositoryService = void 0;
const common_1 = __webpack_require__(3);
const typeorm_1 = __webpack_require__(9);
const typeorm_2 = __webpack_require__(10);
const base_service_1 = __webpack_require__(11);
const RechargeOption_1 = __webpack_require__(20);
let RechargeOptionRepositoryService = class RechargeOptionRepositoryService extends base_service_1.BaseService {
    constructor(repository) {
        super();
        this.repository = repository;
        this.primaryKey = 'id';
    }
};
exports.RechargeOptionRepositoryService = RechargeOptionRepositoryService;
exports.RechargeOptionRepositoryService = RechargeOptionRepositoryService = __decorate([
    (0, common_1.Injectable)(),
    __param(0, (0, typeorm_1.InjectRepository)(RechargeOption_1.RechargeOption)),
    __metadata("design:paramtypes", [typeof (_a = typeof typeorm_2.Repository !== "undefined" && typeorm_2.Repository) === "function" ? _a : Object])
], RechargeOptionRepositoryService);


/***/ }),
/* 20 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.RechargeOption = void 0;
const typeorm_1 = __webpack_require__(10);
let RechargeOption = class RechargeOption {
};
exports.RechargeOption = RechargeOption;
__decorate([
    (0, typeorm_1.PrimaryGeneratedColumn)({ type: "int", name: "id", unsigned: true }),
    __metadata("design:type", Number)
], RechargeOption.prototype, "id", void 0);
__decorate([
    (0, typeorm_1.Column)("decimal", {
        name: "amount",
        comment: "充值金额",
        precision: 6,
        scale: 2,
        default: () => "'0.00'",
    }),
    __metadata("design:type", String)
], RechargeOption.prototype, "amount", void 0);
__decorate([
    (0, typeorm_1.Column)("decimal", {
        name: "reward",
        comment: "奖励金额",
        precision: 6,
        scale: 2,
        default: () => "'0.00'",
    }),
    __metadata("design:type", String)
], RechargeOption.prototype, "reward", void 0);
__decorate([
    (0, typeorm_1.Column)("tinyint", {
        name: "enable",
        comment: "是否启用",
        width: 1,
        default: () => "'0'",
    }),
    __metadata("design:type", Boolean)
], RechargeOption.prototype, "enable", void 0);
exports.RechargeOption = RechargeOption = __decorate([
    (0, typeorm_1.Entity)("recharge_option", { schema: "bacsense_water" })
], RechargeOption);


/***/ }),
/* 21 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
    return function (target, key) { decorator(target, key, paramIndex); }
};
var _a;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.RechargeOrderRepositoryService = void 0;
const common_1 = __webpack_require__(3);
const typeorm_1 = __webpack_require__(9);
const typeorm_2 = __webpack_require__(10);
const base_service_1 = __webpack_require__(11);
const RechargeOrder_1 = __webpack_require__(22);
let RechargeOrderRepositoryService = class RechargeOrderRepositoryService extends base_service_1.BaseService {
    constructor(repository) {
        super();
        this.repository = repository;
        this.primaryKey = 'id';
    }
};
exports.RechargeOrderRepositoryService = RechargeOrderRepositoryService;
exports.RechargeOrderRepositoryService = RechargeOrderRepositoryService = __decorate([
    (0, common_1.Injectable)(),
    __param(0, (0, typeorm_1.InjectRepository)(RechargeOrder_1.RechargeOrder)),
    __metadata("design:paramtypes", [typeof (_a = typeof typeorm_2.Repository !== "undefined" && typeorm_2.Repository) === "function" ? _a : Object])
], RechargeOrderRepositoryService);


/***/ }),
/* 22 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.RechargeOrder = void 0;
const typeorm_1 = __webpack_require__(10);
let RechargeOrder = class RechargeOrder {
};
exports.RechargeOrder = RechargeOrder;
__decorate([
    (0, typeorm_1.PrimaryGeneratedColumn)({ type: "int", name: "id", unsigned: true }),
    __metadata("design:type", Number)
], RechargeOrder.prototype, "id", void 0);
__decorate([
    (0, typeorm_1.Column)("int", { name: "user_id", unsigned: true, default: () => "'0'" }),
    __metadata("design:type", Number)
], RechargeOrder.prototype, "userId", void 0);
__decorate([
    (0, typeorm_1.Column)("tinyint", {
        name: "pay_channel",
        comment: "支付渠道,1:微信，2：支付宝",
        default: () => "'0'",
    }),
    __metadata("design:type", Number)
], RechargeOrder.prototype, "payChannel", void 0);
__decorate([
    (0, typeorm_1.Column)("varchar", { name: "order_no", comment: "订单号", length: 25 }),
    __metadata("design:type", String)
], RechargeOrder.prototype, "orderNo", void 0);
__decorate([
    (0, typeorm_1.Column)("varchar", { name: "trade_no", comment: "交易号", length: 64 }),
    __metadata("design:type", String)
], RechargeOrder.prototype, "tradeNo", void 0);
__decorate([
    (0, typeorm_1.Column)("decimal", {
        name: "amount",
        comment: "支付金额",
        precision: 6,
        scale: 2,
        default: () => "'0.00'",
    }),
    __metadata("design:type", String)
], RechargeOrder.prototype, "amount", void 0);
__decorate([
    (0, typeorm_1.Column)("decimal", {
        name: "reward_amount",
        comment: "奖励的",
        precision: 6,
        scale: 2,
        default: () => "'0.00'",
    }),
    __metadata("design:type", String)
], RechargeOrder.prototype, "rewardAmount", void 0);
__decorate([
    (0, typeorm_1.Column)("tinyint", {
        name: "status",
        comment: "状态",
        unsigned: true,
        default: () => "'0'",
    }),
    __metadata("design:type", Number)
], RechargeOrder.prototype, "status", void 0);
__decorate([
    (0, typeorm_1.Column)("int", {
        name: "create_time",
        comment: "创建时间",
        unsigned: true,
        default: () => "'0'",
    }),
    __metadata("design:type", Number)
], RechargeOrder.prototype, "createTime", void 0);
__decorate([
    (0, typeorm_1.Column)("int", {
        name: "pay_time",
        comment: "支付完成时间",
        unsigned: true,
        default: () => "'0'",
    }),
    __metadata("design:type", Number)
], RechargeOrder.prototype, "payTime", void 0);
exports.RechargeOrder = RechargeOrder = __decorate([
    (0, typeorm_1.Entity)("recharge_order", { schema: "bacsense_water" })
], RechargeOrder);


/***/ }),
/* 23 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
    return function (target, key) { decorator(target, key, paramIndex); }
};
var _a;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.UserRepositoryService = void 0;
const common_1 = __webpack_require__(3);
const base_service_1 = __webpack_require__(11);
const User_1 = __webpack_require__(24);
const typeorm_1 = __webpack_require__(9);
const typeorm_2 = __webpack_require__(10);
let UserRepositoryService = class UserRepositoryService extends base_service_1.BaseService {
    constructor(repository) {
        super();
        this.repository = repository;
        this.primaryKey = 'id';
    }
};
exports.UserRepositoryService = UserRepositoryService;
exports.UserRepositoryService = UserRepositoryService = __decorate([
    (0, common_1.Injectable)(),
    __param(0, (0, typeorm_1.InjectRepository)(User_1.User)),
    __metadata("design:paramtypes", [typeof (_a = typeof typeorm_2.Repository !== "undefined" && typeorm_2.Repository) === "function" ? _a : Object])
], UserRepositoryService);


/***/ }),
/* 24 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.User = void 0;
const typeorm_1 = __webpack_require__(10);
let User = class User {
};
exports.User = User;
__decorate([
    (0, typeorm_1.PrimaryGeneratedColumn)({ type: "int", name: "id", unsigned: true }),
    __metadata("design:type", Number)
], User.prototype, "id", void 0);
__decorate([
    (0, typeorm_1.Column)("varchar", { name: "openid", unique: true, length: 32 }),
    __metadata("design:type", String)
], User.prototype, "openid", void 0);
__decorate([
    (0, typeorm_1.Column)("varchar", { name: "unionid", length: 32 }),
    __metadata("design:type", String)
], User.prototype, "unionid", void 0);
__decorate([
    (0, typeorm_1.Column)("varchar", { name: "nickname", length: 50 }),
    __metadata("design:type", String)
], User.prototype, "nickname", void 0);
__decorate([
    (0, typeorm_1.Column)("varchar", { name: "avatar", length: 100 }),
    __metadata("design:type", String)
], User.prototype, "avatar", void 0);
__decorate([
    (0, typeorm_1.Column)("int", {
        name: "inviter",
        comment: "邀请人",
        unsigned: true,
        default: () => "'0'",
    }),
    __metadata("design:type", Number)
], User.prototype, "inviter", void 0);
__decorate([
    (0, typeorm_1.Column)("char", { name: "phone", nullable: true, length: 11 }),
    __metadata("design:type", String)
], User.prototype, "phone", void 0);
__decorate([
    (0, typeorm_1.Column)("tinyint", { name: "source", default: () => "'0'" }),
    __metadata("design:type", Number)
], User.prototype, "source", void 0);
__decorate([
    (0, typeorm_1.Column)("tinyint", {
        name: "payscore",
        comment: "是否开启支付分0,1",
        default: () => "'0'",
    }),
    __metadata("design:type", Number)
], User.prototype, "payscore", void 0);
__decorate([
    (0, typeorm_1.Column)("decimal", {
        name: "amount",
        precision: 6,
        scale: 2,
        default: () => "'0.00'",
        transformer: {
            to(value) {
                return String(value || 0);
            },
            from(value) {
                return Number(value || 0);
            }
        }
    }),
    __metadata("design:type", Number)
], User.prototype, "amount", void 0);
__decorate([
    (0, typeorm_1.Column)("decimal", {
        name: "reward_amount",
        precision: 6,
        scale: 2,
        default: () => "'0.00'",
        transformer: {
            to(value) {
                return String(value || 0);
            },
            from(value) {
                return Number(value || 0);
            }
        }
    }),
    __metadata("design:type", Number)
], User.prototype, "rewardAmount", void 0);
__decorate([
    (0, typeorm_1.Column)("decimal", {
        name: "freeze_amount",
        precision: 6,
        scale: 2,
        default: () => "'0.00'",
        transformer: {
            to(value) {
                return String(value || 0);
            },
            from(value) {
                return Number(value || 0);
            }
        }
    }),
    __metadata("design:type", Number)
], User.prototype, "freezeAmount", void 0);
__decorate([
    (0, typeorm_1.Column)("int", {
        name: "register_time",
        unsigned: true,
        default: () => "'0'",
    }),
    __metadata("design:type", Number)
], User.prototype, "registerTime", void 0);
__decorate([
    (0, typeorm_1.Column)("int", {
        name: "last_login_time",
        unsigned: true,
        default: () => "'0'",
    }),
    __metadata("design:type", Number)
], User.prototype, "lastLoginTime", void 0);
exports.User = User = __decorate([
    (0, typeorm_1.Index)("openid", ["openid"], { unique: true }),
    (0, typeorm_1.Entity)("user", { schema: "bacsense_water" })
], User);


/***/ }),
/* 25 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
    return function (target, key) { decorator(target, key, paramIndex); }
};
var _a;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.WaterBillsRepositoryService = void 0;
const common_1 = __webpack_require__(3);
const typeorm_1 = __webpack_require__(9);
const typeorm_2 = __webpack_require__(10);
const base_service_1 = __webpack_require__(11);
const WaterBills_1 = __webpack_require__(26);
let WaterBillsRepositoryService = class WaterBillsRepositoryService extends base_service_1.BaseService {
    constructor(repository) {
        super();
        this.repository = repository;
        this.primaryKey = 'id';
    }
};
exports.WaterBillsRepositoryService = WaterBillsRepositoryService;
exports.WaterBillsRepositoryService = WaterBillsRepositoryService = __decorate([
    (0, common_1.Injectable)(),
    __param(0, (0, typeorm_1.InjectRepository)(WaterBills_1.WaterBills)),
    __metadata("design:paramtypes", [typeof (_a = typeof typeorm_2.Repository !== "undefined" && typeorm_2.Repository) === "function" ? _a : Object])
], WaterBillsRepositoryService);


/***/ }),
/* 26 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.WaterBills = void 0;
const typeorm_1 = __webpack_require__(10);
let WaterBills = class WaterBills {
};
exports.WaterBills = WaterBills;
__decorate([
    (0, typeorm_1.PrimaryGeneratedColumn)({ type: "int", name: "id", unsigned: true }),
    __metadata("design:type", Number)
], WaterBills.prototype, "id", void 0);
__decorate([
    (0, typeorm_1.Column)("int", { name: "user_id", unsigned: true, default: () => "'0'" }),
    __metadata("design:type", Number)
], WaterBills.prototype, "userId", void 0);
__decorate([
    (0, typeorm_1.Column)("int", { name: "device_id", unsigned: true, default: () => "'0'" }),
    __metadata("design:type", Number)
], WaterBills.prototype, "deviceId", void 0);
__decorate([
    (0, typeorm_1.Column)("decimal", {
        name: "amount",
        precision: 6,
        scale: 2,
        default: () => "'0.00'",
    }),
    __metadata("design:type", String)
], WaterBills.prototype, "amount", void 0);
__decorate([
    (0, typeorm_1.Column)("int", { name: "water_usage", unsigned: true, default: () => "'0'" }),
    __metadata("design:type", Number)
], WaterBills.prototype, "waterUsage", void 0);
__decorate([
    (0, typeorm_1.Column)("int", { name: "tds_raw", unsigned: true, default: () => "'0'" }),
    __metadata("design:type", Number)
], WaterBills.prototype, "tdsRaw", void 0);
__decorate([
    (0, typeorm_1.Column)("int", { name: "tds_clean", unsigned: true, default: () => "'0'" }),
    __metadata("design:type", Number)
], WaterBills.prototype, "tdsClean", void 0);
__decorate([
    (0, typeorm_1.Column)("int", {
        name: "report_time",
        comment: "上报时间",
        unsigned: true,
        default: () => "'0'",
    }),
    __metadata("design:type", Number)
], WaterBills.prototype, "reportTime", void 0);
__decorate([
    (0, typeorm_1.Column)("int", {
        name: "create_time",
        comment: "创建时间",
        unsigned: true,
        default: () => "'0'",
    }),
    __metadata("design:type", Number)
], WaterBills.prototype, "createTime", void 0);
exports.WaterBills = WaterBills = __decorate([
    (0, typeorm_1.Index)("device_id", ["deviceId"], {}),
    (0, typeorm_1.Entity)("water_bills", { schema: "bacsense_water" })
], WaterBills);


/***/ }),
/* 27 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
    return function (target, key) { decorator(target, key, paramIndex); }
};
var _a;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.WaterTestRepositoryService = void 0;
const common_1 = __webpack_require__(3);
const typeorm_1 = __webpack_require__(9);
const typeorm_2 = __webpack_require__(10);
const base_service_1 = __webpack_require__(11);
const WaterTest_1 = __webpack_require__(28);
let WaterTestRepositoryService = class WaterTestRepositoryService extends base_service_1.BaseService {
    constructor(repository) {
        super();
        this.repository = repository;
        this.primaryKey = 'id';
    }
};
exports.WaterTestRepositoryService = WaterTestRepositoryService;
exports.WaterTestRepositoryService = WaterTestRepositoryService = __decorate([
    (0, common_1.Injectable)(),
    __param(0, (0, typeorm_1.InjectRepository)(WaterTest_1.WaterTest)),
    __metadata("design:paramtypes", [typeof (_a = typeof typeorm_2.Repository !== "undefined" && typeorm_2.Repository) === "function" ? _a : Object])
], WaterTestRepositoryService);


/***/ }),
/* 28 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.WaterTest = void 0;
const typeorm_1 = __webpack_require__(10);
let WaterTest = class WaterTest {
};
exports.WaterTest = WaterTest;
__decorate([
    (0, typeorm_1.PrimaryGeneratedColumn)({ type: "int", name: "id", unsigned: true }),
    __metadata("design:type", Number)
], WaterTest.prototype, "id", void 0);
__decorate([
    (0, typeorm_1.Column)("int", { name: "user_id", unsigned: true, default: () => "'0'" }),
    __metadata("design:type", Number)
], WaterTest.prototype, "userId", void 0);
__decorate([
    (0, typeorm_1.Column)("int", { name: "device_id", unsigned: true, default: () => "'0'" }),
    __metadata("design:type", Number)
], WaterTest.prototype, "deviceId", void 0);
__decorate([
    (0, typeorm_1.Column)("tinyint", {
        name: "status",
        comment: "0：等待开启，1：检测中，2：检测失败，3，结束检测，4：检测停止",
        unsigned: true,
        default: () => "'0'",
    }),
    __metadata("design:type", Number)
], WaterTest.prototype, "status", void 0);
__decorate([
    (0, typeorm_1.Column)("smallint", { name: "result", unsigned: true, default: () => "'0'" }),
    __metadata("design:type", Number)
], WaterTest.prototype, "result", void 0);
__decorate([
    (0, typeorm_1.Column)("int", {
        name: "create_time",
        comment: "创建时间",
        unsigned: true,
        default: () => "'0'",
    }),
    __metadata("design:type", Number)
], WaterTest.prototype, "createTime", void 0);
__decorate([
    (0, typeorm_1.Column)("int", {
        name: "end_time",
        comment: "创建时间",
        unsigned: true,
        default: () => "'0'",
    }),
    __metadata("design:type", Number)
], WaterTest.prototype, "endTime", void 0);
exports.WaterTest = WaterTest = __decorate([
    (0, typeorm_1.Index)("device_id", ["deviceId"], {}),
    (0, typeorm_1.Entity)("water_test", { schema: "bacsense_water" })
], WaterTest);


/***/ }),
/* 29 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
    for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
__exportStar(__webpack_require__(30), exports);
__exportStar(__webpack_require__(31), exports);


/***/ }),
/* 30 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var ConfigureModule_1;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.ConfigureModule = void 0;
const common_1 = __webpack_require__(3);
const configure_service_1 = __webpack_require__(31);
const config_1 = __webpack_require__(32);
const config_2 = __webpack_require__(33);
const fs = __webpack_require__(34);
const path = __webpack_require__(35);
const yaml = __webpack_require__(36);
let ConfigureModule = ConfigureModule_1 = class ConfigureModule {
    static async forRoot(load = null) {
        const loads = [config_2.default];
        if (load) {
            loads.push(load);
        }
        try {
            const folderPath = 'config';
            const files = await fs.promises.readdir(folderPath);
            for (const file of files) {
                const filePath = path.join(folderPath, file);
                loads.push(() => {
                    return yaml.load(fs.readFileSync(filePath, 'utf8'));
                });
            }
        }
        catch (err) {
            console.error(err);
        }
        const options = {
            isGlobal: true,
            expandVariables: true,
            load: loads,
            envFilePath: [`.env.${process.env.APP_NAME}`, '.env', `.env.${process.env.NODE_ENV}`]
        };
        return {
            global: true,
            module: ConfigureModule_1,
            providers: [configure_service_1.ConfigureService],
            exports: [configure_service_1.ConfigureService],
            imports: [
                config_1.ConfigModule.forRoot(options)
            ]
        };
    }
};
exports.ConfigureModule = ConfigureModule;
exports.ConfigureModule = ConfigureModule = ConfigureModule_1 = __decorate([
    (0, common_1.Global)()
], ConfigureModule);


/***/ }),
/* 31 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var _a;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.ConfigureService = void 0;
const common_1 = __webpack_require__(3);
const config_1 = __webpack_require__(32);
let ConfigureService = class ConfigureService {
    constructor(configService) {
        this.configService = configService;
    }
    get(propertyPath) {
        return this.configService.get(propertyPath);
    }
};
exports.ConfigureService = ConfigureService;
exports.ConfigureService = ConfigureService = __decorate([
    (0, common_1.Injectable)(),
    __metadata("design:paramtypes", [typeof (_a = typeof config_1.ConfigService !== "undefined" && config_1.ConfigService) === "function" ? _a : Object])
], ConfigureService);


/***/ }),
/* 32 */
/***/ ((module) => {

module.exports = require("@nestjs/config");

/***/ }),
/* 33 */
/***/ ((__unused_webpack_module, exports) => {


Object.defineProperty(exports, "__esModule", ({ value: true }));
exports["default"] = () => {
    return {
        wxAccessTokenKey: 'wx:access:token',
        startChargeResKey: 'scr:',
        endChargeResKey: 'ecr:',
        userChargingOrderKey: 'ucing:',
        devicePortChargingKeyReg: 'd:?:p:?',
        deviceIdPortToOrderIdReg: '?:?:oid',
        PstartChargeResKey: 'p:scr:',
        PendChargeResKey: 'p:ecr:',
        PdeviceChargingOrderKey: 'p:dcing:',
        aliToDeviceTopicReg: '/?/?/user/alternating/get',
        deviceMsgListKeys: {
            chargeInfo: 'charge:info:list'
        }
    };
};


/***/ }),
/* 34 */
/***/ ((module) => {

module.exports = require("fs");

/***/ }),
/* 35 */
/***/ ((module) => {

module.exports = require("path");

/***/ }),
/* 36 */
/***/ ((module) => {

module.exports = require("js-yaml");

/***/ }),
/* 37 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.DeviceRepositoryModule = void 0;
const common_1 = __webpack_require__(3);
const device_repository_service_1 = __webpack_require__(15);
const typeorm_1 = __webpack_require__(9);
const Device_1 = __webpack_require__(16);
let DeviceRepositoryModule = class DeviceRepositoryModule {
};
exports.DeviceRepositoryModule = DeviceRepositoryModule;
exports.DeviceRepositoryModule = DeviceRepositoryModule = __decorate([
    (0, common_1.Module)({
        imports: [typeorm_1.TypeOrmModule.forFeature([Device_1.Device])],
        providers: [device_repository_service_1.DeviceRepositoryService],
        exports: [device_repository_service_1.DeviceRepositoryService]
    })
], DeviceRepositoryModule);


/***/ }),
/* 38 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.UserRepositoryModule = void 0;
const common_1 = __webpack_require__(3);
const user_repository_service_1 = __webpack_require__(23);
const User_1 = __webpack_require__(24);
const typeorm_1 = __webpack_require__(9);
let UserRepositoryModule = class UserRepositoryModule {
};
exports.UserRepositoryModule = UserRepositoryModule;
exports.UserRepositoryModule = UserRepositoryModule = __decorate([
    (0, common_1.Module)({
        imports: [typeorm_1.TypeOrmModule.forFeature([User_1.User])],
        providers: [user_repository_service_1.UserRepositoryService],
        exports: [user_repository_service_1.UserRepositoryService]
    })
], UserRepositoryModule);


/***/ }),
/* 39 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.RechargeOptionRepositoryModule = void 0;
const common_1 = __webpack_require__(3);
const recharge_option_repository_service_1 = __webpack_require__(19);
const RechargeOption_1 = __webpack_require__(20);
const typeorm_1 = __webpack_require__(9);
let RechargeOptionRepositoryModule = class RechargeOptionRepositoryModule {
};
exports.RechargeOptionRepositoryModule = RechargeOptionRepositoryModule;
exports.RechargeOptionRepositoryModule = RechargeOptionRepositoryModule = __decorate([
    (0, common_1.Module)({
        imports: [typeorm_1.TypeOrmModule.forFeature([RechargeOption_1.RechargeOption])],
        providers: [recharge_option_repository_service_1.RechargeOptionRepositoryService],
        exports: [recharge_option_repository_service_1.RechargeOptionRepositoryService]
    })
], RechargeOptionRepositoryModule);


/***/ }),
/* 40 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.DeviceTypeRepositoryModule = void 0;
const common_1 = __webpack_require__(3);
const device_type_repository_service_1 = __webpack_require__(17);
const typeorm_1 = __webpack_require__(9);
const DeviceType_1 = __webpack_require__(18);
let DeviceTypeRepositoryModule = class DeviceTypeRepositoryModule {
};
exports.DeviceTypeRepositoryModule = DeviceTypeRepositoryModule;
exports.DeviceTypeRepositoryModule = DeviceTypeRepositoryModule = __decorate([
    (0, common_1.Module)({
        imports: [typeorm_1.TypeOrmModule.forFeature([DeviceType_1.DeviceType])],
        providers: [device_type_repository_service_1.DeviceTypeRepositoryService],
        exports: [device_type_repository_service_1.DeviceTypeRepositoryService]
    })
], DeviceTypeRepositoryModule);


/***/ }),
/* 41 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.WaterTestRepositoryModule = void 0;
const common_1 = __webpack_require__(3);
const water_test_repository_service_1 = __webpack_require__(27);
const typeorm_1 = __webpack_require__(9);
const WaterTest_1 = __webpack_require__(28);
let WaterTestRepositoryModule = class WaterTestRepositoryModule {
};
exports.WaterTestRepositoryModule = WaterTestRepositoryModule;
exports.WaterTestRepositoryModule = WaterTestRepositoryModule = __decorate([
    (0, common_1.Module)({
        imports: [typeorm_1.TypeOrmModule.forFeature([WaterTest_1.WaterTest])],
        exports: [water_test_repository_service_1.WaterTestRepositoryService],
        providers: [water_test_repository_service_1.WaterTestRepositoryService]
    })
], WaterTestRepositoryModule);


/***/ }),
/* 42 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.WaterBillsRepositoryModule = void 0;
const common_1 = __webpack_require__(3);
const water_bills_repository_service_1 = __webpack_require__(25);
const typeorm_1 = __webpack_require__(9);
const WaterBills_1 = __webpack_require__(26);
let WaterBillsRepositoryModule = class WaterBillsRepositoryModule {
};
exports.WaterBillsRepositoryModule = WaterBillsRepositoryModule;
exports.WaterBillsRepositoryModule = WaterBillsRepositoryModule = __decorate([
    (0, common_1.Module)({
        imports: [typeorm_1.TypeOrmModule.forFeature([WaterBills_1.WaterBills])],
        exports: [water_bills_repository_service_1.WaterBillsRepositoryService],
        providers: [water_bills_repository_service_1.WaterBillsRepositoryService]
    })
], WaterBillsRepositoryModule);


/***/ }),
/* 43 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.CleanRecordRepositoryModule = void 0;
const common_1 = __webpack_require__(3);
const clean_record_repository_service_1 = __webpack_require__(8);
const typeorm_1 = __webpack_require__(9);
const CleanRecord_1 = __webpack_require__(12);
let CleanRecordRepositoryModule = class CleanRecordRepositoryModule {
};
exports.CleanRecordRepositoryModule = CleanRecordRepositoryModule;
exports.CleanRecordRepositoryModule = CleanRecordRepositoryModule = __decorate([
    (0, common_1.Module)({
        imports: [typeorm_1.TypeOrmModule.forFeature([CleanRecord_1.CleanRecord])],
        providers: [clean_record_repository_service_1.CleanRecordRepositoryService],
        exports: [clean_record_repository_service_1.CleanRecordRepositoryService]
    })
], CleanRecordRepositoryModule);


/***/ }),
/* 44 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.SysConfigRepositoryModule = void 0;
const common_1 = __webpack_require__(3);
const sys_config_repository_service_1 = __webpack_require__(13);
const typeorm_1 = __webpack_require__(9);
const SysConfig_1 = __webpack_require__(14);
let SysConfigRepositoryModule = class SysConfigRepositoryModule {
};
exports.SysConfigRepositoryModule = SysConfigRepositoryModule;
exports.SysConfigRepositoryModule = SysConfigRepositoryModule = __decorate([
    (0, common_1.Module)({
        imports: [typeorm_1.TypeOrmModule.forFeature([SysConfig_1.SysConfig])],
        providers: [sys_config_repository_service_1.SysConfigRepositoryService],
        exports: [sys_config_repository_service_1.SysConfigRepositoryService]
    })
], SysConfigRepositoryModule);


/***/ }),
/* 45 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.RechargeOrderRepositoryModule = void 0;
const common_1 = __webpack_require__(3);
const recharge_order_repository_service_1 = __webpack_require__(21);
const RechargeOrder_1 = __webpack_require__(22);
const typeorm_1 = __webpack_require__(9);
let RechargeOrderRepositoryModule = class RechargeOrderRepositoryModule {
};
exports.RechargeOrderRepositoryModule = RechargeOrderRepositoryModule;
exports.RechargeOrderRepositoryModule = RechargeOrderRepositoryModule = __decorate([
    (0, common_1.Module)({
        imports: [typeorm_1.TypeOrmModule.forFeature([RechargeOrder_1.RechargeOrder])],
        providers: [recharge_order_repository_service_1.RechargeOrderRepositoryService],
        exports: [recharge_order_repository_service_1.RechargeOrderRepositoryService]
    })
], RechargeOrderRepositoryModule);


/***/ }),
/* 46 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
    for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
__exportStar(__webpack_require__(47), exports);
__exportStar(__webpack_require__(49), exports);


/***/ }),
/* 47 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.CacheModule = void 0;
const common_1 = __webpack_require__(3);
const cache_manager_1 = __webpack_require__(48);
const cache_service_1 = __webpack_require__(49);
const configure_1 = __webpack_require__(29);
const cache_manager_ioredis_yet_1 = __webpack_require__(51);
let CacheModule = class CacheModule {
};
exports.CacheModule = CacheModule;
exports.CacheModule = CacheModule = __decorate([
    (0, common_1.Global)(),
    (0, common_1.Module)({
        imports: [cache_manager_1.CacheModule.registerAsync({
                imports: [configure_1.ConfigureModule],
                inject: [configure_1.ConfigureService],
                useFactory: (config) => {
                    return {
                        store: cache_manager_ioredis_yet_1.redisStore,
                        ...config.get('cache')
                    };
                }
            })],
        providers: [cache_service_1.CacheService],
        exports: [cache_service_1.CacheService],
    })
], CacheModule);


/***/ }),
/* 48 */
/***/ ((module) => {

module.exports = require("@nestjs/cache-manager");

/***/ }),
/* 49 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
    return function (target, key) { decorator(target, key, paramIndex); }
};
var _a;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.CacheService = void 0;
const cache_manager_1 = __webpack_require__(48);
const common_1 = __webpack_require__(3);
const cache_manager_2 = __webpack_require__(50);
let CacheService = class CacheService {
    constructor(cacheManager) {
        this.cacheManager = cacheManager;
        this.Client = this.cacheManager.store.client;
    }
    get client() {
        return this.Client;
    }
    async set(...args) {
        let res;
        let argsLen = args.length;
        if (argsLen == 2) {
            res = await this.Client.set(args[0], args[1]);
        }
        else if (argsLen == 3) {
            res = await this.Client.set(args[0], args[1], 'EX', args[2]);
        }
        else if (argsLen == 4) {
            res = await this.Client.set(args[0], args[1], 'EX', args[2], 'NX');
        }
        return res === 'OK';
    }
    pop(key) {
        return this.Client.rpop(key);
    }
    get(key) {
        return this.Client.get(key);
    }
    del(...keys) {
        return this.Client.del(...keys);
    }
    blpop(key, timeout) {
        return this.Client.blpop(key, timeout);
    }
    async blockLock(key, timeout) {
        const len = await this.Client.llen(key);
        if (len == 0) {
            const rs = await this.set(key + ':nx', '1', timeout + 3, 'NX');
            if (rs) {
                return true;
            }
        }
        const res = await this.blpop(key, timeout);
        return res ? true : false;
    }
    async unBlockLock(key) {
        this.Client.lpush(key, '1');
    }
    hmset(key, data) {
        this.Client.hmset(key, data);
    }
    hgetall(key) {
        return this.Client.hgetall(key);
    }
};
exports.CacheService = CacheService;
exports.CacheService = CacheService = __decorate([
    (0, common_1.Injectable)(),
    __param(0, (0, common_1.Inject)(cache_manager_1.CACHE_MANAGER)),
    __metadata("design:paramtypes", [typeof (_a = typeof cache_manager_2.Cache !== "undefined" && cache_manager_2.Cache) === "function" ? _a : Object])
], CacheService);


/***/ }),
/* 50 */
/***/ ((module) => {

module.exports = require("cache-manager");

/***/ }),
/* 51 */
/***/ ((module) => {

module.exports = require("cache-manager-ioredis-yet");

/***/ }),
/* 52 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.UserModule = void 0;
const common_1 = __webpack_require__(3);
const user_service_1 = __webpack_require__(53);
const user_controller_1 = __webpack_require__(54);
let UserModule = class UserModule {
};
exports.UserModule = UserModule;
exports.UserModule = UserModule = __decorate([
    (0, common_1.Module)({
        providers: [user_service_1.UserService],
        controllers: [user_controller_1.UserController],
        exports: [user_service_1.UserService]
    })
], UserModule);


/***/ }),
/* 53 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var _a, _b;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.UserService = void 0;
const common_1 = __webpack_require__(3);
const db_service_1 = __webpack_require__(7);
const cache_1 = __webpack_require__(46);
let UserService = class UserService {
    constructor(db, cache) {
        this.db = db;
        this.cache = cache;
        this.prefix = 'user:';
    }
    setCache(id, user) {
        return this.cache.hmset(this.prefix + id, user);
    }
    getFromCache(id) {
        return this.cache.hgetall(this.prefix + id);
    }
    async getUserBalance(userId) {
        return this.db.user.findOne({ id: userId }, ['amount', 'rewardAmount']);
    }
};
exports.UserService = UserService;
exports.UserService = UserService = __decorate([
    (0, common_1.Injectable)(),
    __metadata("design:paramtypes", [typeof (_a = typeof db_service_1.DbService !== "undefined" && db_service_1.DbService) === "function" ? _a : Object, typeof (_b = typeof cache_1.CacheService !== "undefined" && cache_1.CacheService) === "function" ? _b : Object])
], UserService);


/***/ }),
/* 54 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
    return function (target, key) { decorator(target, key, paramIndex); }
};
var _a;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.UserController = void 0;
const common_1 = __webpack_require__(3);
const user_service_1 = __webpack_require__(53);
const constant_1 = __webpack_require__(55);
const response_util_1 = __webpack_require__(56);
let UserController = class UserController {
    constructor(service) {
        this.service = service;
    }
    async balanceList(req) {
        const r = await this.service.getUserBalance(req[constant_1.ReqAttrs.USER_ID]);
        return response_util_1.ResponseUtilService.successRes(r);
    }
};
exports.UserController = UserController;
__decorate([
    (0, common_1.Get)('balance/list'),
    __param(0, (0, common_1.Req)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object]),
    __metadata("design:returntype", Promise)
], UserController.prototype, "balanceList", null);
exports.UserController = UserController = __decorate([
    (0, common_1.Controller)('user'),
    __metadata("design:paramtypes", [typeof (_a = typeof user_service_1.UserService !== "undefined" && user_service_1.UserService) === "function" ? _a : Object])
], UserController);


/***/ }),
/* 55 */
/***/ ((__unused_webpack_module, exports) => {


Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.ReqAttrs = void 0;
exports.ReqAttrs = {
    USER_ID: 'userId',
    IS_WX: 'isWx',
    IS_ALI: 'isAli',
    CLIENT_SOURCE: 'clientSource'
};


/***/ }),
/* 56 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
    for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
__exportStar(__webpack_require__(57), exports);
__exportStar(__webpack_require__(58), exports);


/***/ }),
/* 57 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.ResponseUtilModule = void 0;
const common_1 = __webpack_require__(3);
const response_util_service_1 = __webpack_require__(58);
let ResponseUtilModule = class ResponseUtilModule {
};
exports.ResponseUtilModule = ResponseUtilModule;
exports.ResponseUtilModule = ResponseUtilModule = __decorate([
    (0, common_1.Global)(),
    (0, common_1.Module)({
        providers: [response_util_service_1.ResponseUtilService],
        exports: [response_util_service_1.ResponseUtilService],
    })
], ResponseUtilModule);


/***/ }),
/* 58 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.ResponseUtilService = void 0;
const common_1 = __webpack_require__(3);
let ResponseUtilService = class ResponseUtilService {
    static successRes(data = null, params, msg) {
        let result = {
            success: true,
            data: null,
            msg: msg,
            code: 0
        };
        if (data !== null) {
            result.data = data;
        }
        if (params) {
            result = Object.assign(result, params);
        }
        return result;
    }
    static failRes(msg, params) {
        let result = {
            success: false,
            data: null,
            msg: msg,
            code: 0
        };
        if (msg !== undefined) {
            result.msg = msg;
        }
        if (params) {
            result = Object.assign(result, params);
        }
        return result;
    }
};
exports.ResponseUtilService = ResponseUtilService;
exports.ResponseUtilService = ResponseUtilService = __decorate([
    (0, common_1.Injectable)()
], ResponseUtilService);


/***/ }),
/* 59 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.LoginModule = void 0;
const common_1 = __webpack_require__(3);
const login_service_1 = __webpack_require__(60);
const login_controller_1 = __webpack_require__(73);
const user_module_1 = __webpack_require__(52);
const jwt_verify_1 = __webpack_require__(69);
let LoginModule = class LoginModule {
};
exports.LoginModule = LoginModule;
exports.LoginModule = LoginModule = __decorate([
    (0, common_1.Module)({
        imports: [user_module_1.UserModule, jwt_verify_1.JwtVerifyModule],
        providers: [login_service_1.LoginService],
        controllers: [login_controller_1.LoginController]
    })
], LoginModule);


/***/ }),
/* 60 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var _a, _b, _c, _d, _e;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.LoginService = void 0;
const wechat_1 = __webpack_require__(61);
const common_1 = __webpack_require__(3);
const db_service_1 = __webpack_require__(7);
const User_1 = __webpack_require__(24);
const USER_SOURCE_1 = __webpack_require__(68);
const user_service_1 = __webpack_require__(53);
const configure_1 = __webpack_require__(29);
const jwt_verify_1 = __webpack_require__(69);
let LoginService = class LoginService {
    constructor(userService, wechat, db, config, jwt) {
        this.userService = userService;
        this.wechat = wechat;
        this.db = db;
        this.config = config;
        this.jwt = jwt;
        this.jwtExpire = 0;
        this.jwtExpire = Number(this.config.get('JWT_EXPIRE'));
    }
    async login(code, isWx) {
        this.db.cleanRecord.insert({ userId: 1001030, deviceId: 1001030, createTime: Math.floor(Date.now() / 1000), status: 0, err: 0 });
        const data = await this.wechat.login(code);
        if (data == null)
            return null;
        const openid = data.openid;
        const time = Math.floor(Date.now() / 1000);
        let user = await this.db.user.findOne({ openid: openid }, ['id', 'source', 'nickname', 'avatar', 'phone']);
        if (!user) {
            user = new User_1.User();
            user.amount = 0;
            user.rewardAmount = 0;
            user.freezeAmount = 0;
            user.openid = openid;
            user.source = isWx ? USER_SOURCE_1.USER_SOURCE.WX : USER_SOURCE_1.USER_SOURCE.ALI;
            user.registerTime = time;
            user.phone = null;
            const res = await this.db.user.insert(user);
            if (!res)
                return null;
            user.id = res.rows[0].id;
        }
        else {
            this.db.user.update({ id: user.id }, {
                lastLoginTime: time,
            });
        }
        let cacheData = {
            source: user.source,
            openid: openid
        };
        if (isWx) {
            cacheData.session_key = data.session_key;
            if (data.unionid) {
                cacheData.unionid = data.unionid;
            }
        }
        else {
        }
        this.userService.setCache(user.id, cacheData);
        const accessToken = this.jwt.sign({ key: user.id, id: Math.ceil((time - 1030) / 263), time: time }, this.jwtExpire);
        return {
            accessToken,
            refreshToken: '',
            expire: this.jwtExpire,
            user: {
                nickname: user.nickname || '',
                avatar: user.avatar || '',
                phoneAuth: user.phone != null
            }
        };
    }
};
exports.LoginService = LoginService;
exports.LoginService = LoginService = __decorate([
    (0, common_1.Injectable)(),
    __metadata("design:paramtypes", [typeof (_a = typeof user_service_1.UserService !== "undefined" && user_service_1.UserService) === "function" ? _a : Object, typeof (_b = typeof wechat_1.WechatService !== "undefined" && wechat_1.WechatService) === "function" ? _b : Object, typeof (_c = typeof db_service_1.DbService !== "undefined" && db_service_1.DbService) === "function" ? _c : Object, typeof (_d = typeof configure_1.ConfigureService !== "undefined" && configure_1.ConfigureService) === "function" ? _d : Object, typeof (_e = typeof jwt_verify_1.JwtVerifyService !== "undefined" && jwt_verify_1.JwtVerifyService) === "function" ? _e : Object])
], LoginService);


/***/ }),
/* 61 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
    for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
__exportStar(__webpack_require__(62), exports);
__exportStar(__webpack_require__(63), exports);


/***/ }),
/* 62 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var WechatModule_1;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.WechatModule = void 0;
const common_1 = __webpack_require__(3);
const wechat_service_1 = __webpack_require__(63);
const axios_1 = __webpack_require__(64);
let WechatModule = WechatModule_1 = class WechatModule {
    static forRootAsync(options) {
        const providers = [
            {
                provide: 'WECHAT_CONFIG',
                useFactory: options.useFactory,
                inject: options.inject || [],
            },
            wechat_service_1.WechatService,
        ];
        return {
            module: WechatModule_1,
            providers: providers,
            exports: [wechat_service_1.WechatService],
        };
    }
};
exports.WechatModule = WechatModule;
exports.WechatModule = WechatModule = WechatModule_1 = __decorate([
    (0, common_1.Global)(),
    (0, common_1.Module)({
        imports: [axios_1.HttpModule]
    })
], WechatModule);


/***/ }),
/* 63 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
    return function (target, key) { decorator(target, key, paramIndex); }
};
var _a, _b;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.WechatService = void 0;
const axios_1 = __webpack_require__(64);
const common_1 = __webpack_require__(3);
const WechatConfig_1 = __webpack_require__(65);
const WxPay = __webpack_require__(66);
const url = __webpack_require__(67);
let WechatService = class WechatService {
    constructor(config, http) {
        this.config = config;
        this.http = http;
    }
    async login(code) {
        const res = await this.http.axiosRef.get('https://api.weixin.qq.com/sns/jscode2session', {
            params: {
                appid: this.config.appid,
                secret: this.config.secret,
                grant_type: 'authorization_code',
                js_code: code
            }
        });
        return res.statusText == 'OK' ? res.data : null;
    }
    async getuserphonenumber(code, accessToken) {
        try {
            const res = await this.http.axiosRef.post('https://api.weixin.qq.com/wxa/business/getuserphonenumber?access_token=' + accessToken, {
                code
            });
            if (res.statusText == 'OK' && res.data) {
                if (res.data.errcode == 0) {
                    return res.data.phone_info.phoneNumber;
                }
            }
        }
        catch (error) {
            console.log(error.message);
        }
        return null;
    }
    async getWXAccessToken() {
        const res = await this.http.axiosRef.get('https://api.weixin.qq.com/cgi-bin/token', {
            params: {
                grant_type: 'client_credential',
                appid: this.config.appid,
                secret: this.config.secret
            }
        });
        if (res.statusText == 'OK') {
            if (res.data && res.data.access_token) {
                return res.data.access_token;
            }
            else {
                console.log(res.data);
            }
        }
        return null;
    }
    async decipher_gcm(ciphertext, associated_data, nonce) {
        const pay = new WxPay({
            appid: this.config.appid,
            mchid: this.config.mchid,
            publicKey: Buffer.from(this.config.publicKey, 'utf-8'),
            privateKey: Buffer.from(this.config.privateKey, 'utf-8'),
        });
        return pay.decipher_gcm(ciphertext, associated_data, nonce, this.config.v3Key);
    }
    async pay(amount, orderNo, openid, description, notify_url) {
        const pay = new WxPay({
            appid: this.config.appid,
            mchid: this.config.mchid,
            publicKey: Buffer.from(this.config.publicKey, 'utf-8'),
            privateKey: Buffer.from(this.config.privateKey, 'utf-8'),
        });
        let baseNotifyUrl = this.config.baseNotifyUrl;
        if (baseNotifyUrl.endsWith('/') == false) {
            baseNotifyUrl += '/';
        }
        const result = await pay.transactions_jsapi({
            description: description,
            out_trade_no: orderNo,
            notify_url: url.resolve(baseNotifyUrl, notify_url),
            amount: {
                total: amount * 100,
            },
            payer: {
                openid: openid,
            }
        });
        console.log(result);
        if (result.status != 200)
            return null;
        return {
            appId: result.appId,
            timeStamp: result.timeStamp,
            nonceStr: result.nonceStr,
            package: result.package,
            signType: result.signType,
            paySign: result.paySign,
        };
    }
};
exports.WechatService = WechatService;
exports.WechatService = WechatService = __decorate([
    (0, common_1.Injectable)(),
    __param(0, (0, common_1.Inject)('WECHAT_CONFIG')),
    __metadata("design:paramtypes", [typeof (_a = typeof WechatConfig_1.WechatConfig !== "undefined" && WechatConfig_1.WechatConfig) === "function" ? _a : Object, typeof (_b = typeof axios_1.HttpService !== "undefined" && axios_1.HttpService) === "function" ? _b : Object])
], WechatService);


/***/ }),
/* 64 */
/***/ ((module) => {

module.exports = require("@nestjs/axios");

/***/ }),
/* 65 */
/***/ ((__unused_webpack_module, exports) => {


Object.defineProperty(exports, "__esModule", ({ value: true }));


/***/ }),
/* 66 */
/***/ ((module) => {

module.exports = require("wechatpay-node-v3");

/***/ }),
/* 67 */
/***/ ((module) => {

module.exports = require("url");

/***/ }),
/* 68 */
/***/ ((__unused_webpack_module, exports) => {


Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.USER_SOURCE = void 0;
exports.USER_SOURCE = {
    WX: 1,
    ALI: 2
};


/***/ }),
/* 69 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
    for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
__exportStar(__webpack_require__(70), exports);
__exportStar(__webpack_require__(71), exports);


/***/ }),
/* 70 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.JwtVerifyModule = void 0;
const common_1 = __webpack_require__(3);
const jwt_verify_service_1 = __webpack_require__(71);
const jwt_1 = __webpack_require__(72);
let JwtVerifyModule = class JwtVerifyModule {
};
exports.JwtVerifyModule = JwtVerifyModule;
exports.JwtVerifyModule = JwtVerifyModule = __decorate([
    (0, common_1.Global)(),
    (0, common_1.Module)({
        imports: [jwt_1.JwtModule.register({})],
        providers: [jwt_verify_service_1.JwtVerifyService],
        exports: [jwt_verify_service_1.JwtVerifyService],
    })
], JwtVerifyModule);


/***/ }),
/* 71 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var _a;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.JwtVerifyService = void 0;
const common_1 = __webpack_require__(3);
const jwt_1 = __webpack_require__(72);
let JwtVerifyService = class JwtVerifyService {
    constructor(jwtService) {
        this.jwtService = jwtService;
        this.secretLen = 15;
        this.pos = 5;
    }
    sign(payload, expire) {
        const secret = this.getRandomNChars(this.secretLen);
        let token = this.jwtService.sign(payload, {
            secret,
            expiresIn: expire
        });
        return this.mixUp(token, secret);
    }
    verify(token) {
        try {
            if (token === null)
                return null;
            const tokens = token.split(",");
            const tokenStr1 = tokens[1];
            const tokenStr2 = tokens[2];
            const str1 = tokenStr1.substring(this.pos, this.pos + this.pos + this.secretLen);
            tokens[1] = tokenStr1.substring(0, this.pos) + tokenStr1.substring(this.pos + this.pos + this.secretLen);
            tokens[2] = tokenStr2.substring(0, this.pos) + tokenStr2.substring(this.pos + this.pos);
            token = tokens.join(".");
            const secret = str1.substring(0, this.secretLen);
            return this.jwtService.verify(token, {
                secret
            });
        }
        catch (error) {
        }
        return null;
    }
    getRandomNChars(n) {
        const randomString = "1qwZYeX2rTtCSDFGHJKLy3m4V5uU6B7ioNp89aMRxvnASDFsdfgQh0WEjIkl";
        let characters = [...randomString];
        for (let i = characters.length - 1; i > 0; i--) {
            const j = Math.floor(Math.random() * (i + 1));
            [characters[i], characters[j]] = [characters[j], characters[i]];
        }
        const result = new Array(n).fill(null);
        for (let i = 0; i < n; i++) {
            const index = Math.floor(Math.random() * characters.length);
            result[i] = characters[index];
        }
        return result.join('');
    }
    mixUp(token, secret) {
        const str1 = secret + this.getRandomNChars(this.pos);
        const str2 = this.getRandomNChars(this.pos);
        const tokens = token.split('.');
        const tokenStr1 = tokens[1];
        const tokenStr2 = tokens[2];
        tokens[1] = tokenStr1.substring(0, this.pos) + str1 + tokenStr1.substring(this.pos);
        tokens[2] = tokenStr2.substring(0, this.pos) + str2 + tokenStr2.substring(this.pos);
        return tokens.join(',');
    }
};
exports.JwtVerifyService = JwtVerifyService;
exports.JwtVerifyService = JwtVerifyService = __decorate([
    (0, common_1.Injectable)(),
    __metadata("design:paramtypes", [typeof (_a = typeof jwt_1.JwtService !== "undefined" && jwt_1.JwtService) === "function" ? _a : Object])
], JwtVerifyService);


/***/ }),
/* 72 */
/***/ ((module) => {

module.exports = require("@nestjs/jwt");

/***/ }),
/* 73 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
    return function (target, key) { decorator(target, key, paramIndex); }
};
var _a, _b;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.LoginController = void 0;
const common_1 = __webpack_require__(3);
const login_service_1 = __webpack_require__(60);
const response_util_1 = __webpack_require__(56);
let LoginController = class LoginController {
    constructor(service) {
        this.service = service;
    }
    async login(code, req, ip) {
        const r = await this.service.login(code, true);
        return r ? response_util_1.ResponseUtilService.successRes(r) : response_util_1.ResponseUtilService.failRes();
    }
};
exports.LoginController = LoginController;
__decorate([
    (0, common_1.Post)(),
    __param(0, (0, common_1.Body)('code')),
    __param(1, (0, common_1.Req)()),
    __param(2, (0, common_1.Ip)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, typeof (_b = typeof ReqAttrs !== "undefined" && ReqAttrs) === "function" ? _b : Object, String]),
    __metadata("design:returntype", Promise)
], LoginController.prototype, "login", null);
exports.LoginController = LoginController = __decorate([
    (0, common_1.Controller)('login'),
    __metadata("design:paramtypes", [typeof (_a = typeof login_service_1.LoginService !== "undefined" && login_service_1.LoginService) === "function" ? _a : Object])
], LoginController);


/***/ }),
/* 74 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.ScheduleModule = void 0;
const common_1 = __webpack_require__(3);
const schedule_service_1 = __webpack_require__(75);
const schedule_1 = __webpack_require__(76);
let ScheduleModule = class ScheduleModule {
};
exports.ScheduleModule = ScheduleModule;
exports.ScheduleModule = ScheduleModule = __decorate([
    (0, common_1.Module)({
        imports: [schedule_1.ScheduleModule.forRoot()],
        providers: [schedule_service_1.ScheduleService]
    })
], ScheduleModule);


/***/ }),
/* 75 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var _a, _b, _c;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.ScheduleService = void 0;
const cache_1 = __webpack_require__(46);
const configure_1 = __webpack_require__(29);
const wechat_1 = __webpack_require__(61);
const common_1 = __webpack_require__(3);
const schedule_1 = __webpack_require__(76);
let ScheduleService = class ScheduleService {
    constructor(wechat, config, cache) {
        this.wechat = wechat;
        this.config = config;
        this.cache = cache;
    }
    onModuleInit() {
        this.getWxAccessToken();
    }
    wxAccessToken() {
        console.log((new Date()).toLocaleTimeString());
        this.getWxAccessToken();
    }
    async getWxAccessToken() {
        const r = await this.cache.client.ttl(this.config.get('wxAccessTokenKey'));
        console.log(r);
        if (r > (60 * 60 + 100))
            return;
        this.wechat.getWXAccessToken().then(token => {
            if (token != null) {
                this.cache.set(this.config.get('wxAccessTokenKey'), token, 2 * 60 * 60);
            }
        });
    }
};
exports.ScheduleService = ScheduleService;
__decorate([
    (0, schedule_1.Cron)('0 * * * *'),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", []),
    __metadata("design:returntype", void 0)
], ScheduleService.prototype, "wxAccessToken", null);
exports.ScheduleService = ScheduleService = __decorate([
    (0, common_1.Injectable)(),
    __metadata("design:paramtypes", [typeof (_a = typeof wechat_1.WechatService !== "undefined" && wechat_1.WechatService) === "function" ? _a : Object, typeof (_b = typeof configure_1.ConfigureService !== "undefined" && configure_1.ConfigureService) === "function" ? _b : Object, typeof (_c = typeof cache_1.CacheService !== "undefined" && cache_1.CacheService) === "function" ? _c : Object])
], ScheduleService);


/***/ }),
/* 76 */
/***/ ((module) => {

module.exports = require("@nestjs/schedule");

/***/ }),
/* 77 */
/***/ ((__unused_webpack_module, exports) => {


Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.SYS_CONFIG = void 0;
exports.SYS_CONFIG = {
    aliCloud: 'ALI_CLOUD',
    accessKeyId: 'accessKeyId',
    accessKeySecret: 'accessKeySecret',
    regionId: 'regionId',
    instanceId: 'instanceId',
    wechat: 'WECHAT',
    appid: 'appid',
    mchid: 'mchid',
    v3Key: 'v3Key',
    secret: 'secret',
    publicKey: 'publicKey',
    privateKey: 'privateKey',
    baseNotifyUrl: 'baseNotifyUrl'
};


/***/ }),
/* 78 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.RechargeModule = void 0;
const common_1 = __webpack_require__(3);
const recharge_service_1 = __webpack_require__(79);
const recharge_controller_1 = __webpack_require__(82);
let RechargeModule = class RechargeModule {
};
exports.RechargeModule = RechargeModule;
exports.RechargeModule = RechargeModule = __decorate([
    (0, common_1.Module)({
        providers: [recharge_service_1.RechargeService],
        controllers: [recharge_controller_1.RechargeController]
    })
], RechargeModule);


/***/ }),
/* 79 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var _a, _b, _c, _d;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.RechargeService = void 0;
const common_1 = __webpack_require__(3);
const db_service_1 = __webpack_require__(7);
const RechargeOrder_1 = __webpack_require__(22);
const wechat_1 = __webpack_require__(61);
const cache_1 = __webpack_require__(46);
const User_1 = __webpack_require__(24);
const UserWalletLog_1 = __webpack_require__(80);
const typeorm_1 = __webpack_require__(10);
const WALLET_LOG_TYPE_1 = __webpack_require__(81);
let RechargeService = class RechargeService {
    constructor(db, wechat, cache, dataSource) {
        this.db = db;
        this.wechat = wechat;
        this.cache = cache;
        this.dataSource = dataSource;
    }
    options() {
        return this.db.rechargeOption.find(null, null, null, null, { id: 'DESC' });
    }
    generateOrderNo(userId) {
        const date = new Date();
        const time = Math.floor(date.getTime() / 1000) % 1000000;
        const year = date.getFullYear() % 100;
        const month = String(date.getMonth() + 1).padStart(2, '0');
        const day = String(date.getDate()).padStart(2, '0');
        return year + month + day + time + String(userId).padStart(10, '0');
    }
    async recharge(id, userId, clientSource, isWx) {
        const option = await this.db.rechargeOption.findOne({ id: id }, { amount: true, reward: true });
        if (!option)
            return null;
        const user = await this.db.user.findOne({ id: userId }, { id: true, openid: true });
        let time = Math.floor(Date.now() / 1000);
        const orderNo = this.generateOrderNo(userId);
        let order = {
            orderNo: orderNo,
            amount: option.amount,
            rewardAmount: option.reward,
            payChannel: clientSource,
            userId: userId,
            createTime: time
        };
        const res = await this.db.rechargeOrder.insert(order);
        if (res != null && res.affectedRows > 0) {
            const _id = res.rows[0][this.db.rechargeOrder.primaryKey];
            const notifyUrl = 'recharge/notify/';
            return this.wechat.pay(Number(option.amount), orderNo, user.openid, '充值', notifyUrl + 'wx/' + _id);
        }
        return null;
    }
    async notify(id, data, isWx) {
        const lockKey = 'p:n:l' + id;
        const lock = await this.cache.set(lockKey, '1', 20, 'NX');
        if (!lock)
            return false;
        const order = await this.db.rechargeOrder.findOne({ id: id }, { orderNo: true, userId: true, status: true, amount: true, rewardAmount: true });
        if (!order || order.status != 0) {
            return true;
        }
        let tradeNo = '';
        if (isWx) {
            try {
                const res = await this.wechat.decipher_gcm(data.ciphertext, data.associated_data, data.nonce);
                if (res.trade_state != 'SUCCESS' || res.out_trade_no != order.orderNo || res.amount.total != (Number(order.amount) * 100))
                    return false;
                tradeNo = res.transaction_id;
            }
            catch (error) {
                this.cache.del(lockKey);
                console.log(error);
                return false;
            }
        }
        else {
        }
        const time = Math.floor(Date.now() / 1000);
        const queryRunner = await this.dataSource.createQueryRunner();
        await queryRunner.connect();
        await queryRunner.startTransaction();
        try {
            let user = await queryRunner.manager.findOne(User_1.User, {
                where: { id: order.userId },
                select: ['amount', 'rewardAmount'],
                lock: {
                    mode: 'pessimistic_read'
                }
            });
            let updateData = {
                amount: (Number(user.amount) + Number(order.amount))
            };
            const log = {
                amount: order.amount,
                beforeAmount: String(user.amount),
                beforeRewardAmount: String(user.rewardAmount),
                afterAmount: updateData.amount.toFixed(2),
                userId: order.userId,
                createTime: time,
                type: WALLET_LOG_TYPE_1.WALLET_LOG_TYPE.RECHARGE
            };
            const rewardAmount = Number(order.rewardAmount);
            if (rewardAmount > 0) {
                updateData.rewardAmount = (Number(user.rewardAmount) + rewardAmount);
                log.rewardAmount = order.rewardAmount;
                log.afterRewardAmount = updateData.rewardAmount.toFixed(2);
            }
            const r1 = await queryRunner.manager.update(User_1.User, { id: order.userId }, updateData);
            if (r1.affected < 1) {
                await queryRunner.rollbackTransaction();
                return false;
            }
            const r2 = await queryRunner.manager.update(RechargeOrder_1.RechargeOrder, { id: id }, {
                status: 1,
                tradeNo: tradeNo,
                payTime: time
            });
            if (r2.affected < 1) {
                await queryRunner.rollbackTransaction();
                return false;
            }
            log.relationId = id;
            const r3 = await queryRunner.manager.insert(UserWalletLog_1.UserWalletLog, log);
            if (!r3.raw || r3.raw.affectedRows < 1) {
                await queryRunner.rollbackTransaction();
                return false;
            }
            await queryRunner.commitTransaction();
            return true;
        }
        catch (error) {
            console.log(error);
            await queryRunner.rollbackTransaction();
            return false;
        }
        finally {
            this.cache.del(lockKey);
            await queryRunner.release();
        }
    }
};
exports.RechargeService = RechargeService;
exports.RechargeService = RechargeService = __decorate([
    (0, common_1.Injectable)(),
    __metadata("design:paramtypes", [typeof (_a = typeof db_service_1.DbService !== "undefined" && db_service_1.DbService) === "function" ? _a : Object, typeof (_b = typeof wechat_1.WechatService !== "undefined" && wechat_1.WechatService) === "function" ? _b : Object, typeof (_c = typeof cache_1.CacheService !== "undefined" && cache_1.CacheService) === "function" ? _c : Object, typeof (_d = typeof typeorm_1.DataSource !== "undefined" && typeorm_1.DataSource) === "function" ? _d : Object])
], RechargeService);


/***/ }),
/* 80 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.UserWalletLog = void 0;
const typeorm_1 = __webpack_require__(10);
let UserWalletLog = class UserWalletLog {
};
exports.UserWalletLog = UserWalletLog;
__decorate([
    (0, typeorm_1.PrimaryGeneratedColumn)({ type: "int", name: "id", unsigned: true }),
    __metadata("design:type", Number)
], UserWalletLog.prototype, "id", void 0);
__decorate([
    (0, typeorm_1.Column)("int", { name: "user_id", unsigned: true, default: () => "'0'" }),
    __metadata("design:type", Number)
], UserWalletLog.prototype, "userId", void 0);
__decorate([
    (0, typeorm_1.Column)("int", { name: "relation_id", unsigned: true, default: () => "'0'" }),
    __metadata("design:type", Number)
], UserWalletLog.prototype, "relationId", void 0);
__decorate([
    (0, typeorm_1.Column)("decimal", {
        name: "amount",
        precision: 6,
        scale: 2,
        default: () => "'0.00'",
    }),
    __metadata("design:type", String)
], UserWalletLog.prototype, "amount", void 0);
__decorate([
    (0, typeorm_1.Column)("decimal", {
        name: "reward_amount",
        precision: 6,
        scale: 2,
        default: () => "'0.00'",
    }),
    __metadata("design:type", String)
], UserWalletLog.prototype, "rewardAmount", void 0);
__decorate([
    (0, typeorm_1.Column)("decimal", {
        name: "before_amount",
        precision: 6,
        scale: 2,
        default: () => "'0.00'",
    }),
    __metadata("design:type", String)
], UserWalletLog.prototype, "beforeAmount", void 0);
__decorate([
    (0, typeorm_1.Column)("decimal", {
        name: "before_reward_amount",
        precision: 6,
        scale: 2,
        default: () => "'0.00'",
    }),
    __metadata("design:type", String)
], UserWalletLog.prototype, "beforeRewardAmount", void 0);
__decorate([
    (0, typeorm_1.Column)("decimal", {
        name: "after_amount",
        precision: 6,
        scale: 2,
        default: () => "'0.00'",
    }),
    __metadata("design:type", String)
], UserWalletLog.prototype, "afterAmount", void 0);
__decorate([
    (0, typeorm_1.Column)("decimal", {
        name: "after_reward_amount",
        precision: 6,
        scale: 2,
        default: () => "'0.00'",
    }),
    __metadata("design:type", String)
], UserWalletLog.prototype, "afterRewardAmount", void 0);
__decorate([
    (0, typeorm_1.Column)("tinyint", {
        name: "type",
        comment: "1,充值，2，水费扣费",
        unsigned: true,
        default: () => "'0'",
    }),
    __metadata("design:type", Number)
], UserWalletLog.prototype, "type", void 0);
__decorate([
    (0, typeorm_1.Column)("int", {
        name: "create_time",
        comment: "创建时间",
        unsigned: true,
        default: () => "'0'",
    }),
    __metadata("design:type", Number)
], UserWalletLog.prototype, "createTime", void 0);
exports.UserWalletLog = UserWalletLog = __decorate([
    (0, typeorm_1.Index)("user_id", ["userId"], {}),
    (0, typeorm_1.Entity)("user_wallet_log", { schema: "bacsense_water" })
], UserWalletLog);


/***/ }),
/* 81 */
/***/ ((__unused_webpack_module, exports) => {


Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.WALLET_LOG_TYPE = void 0;
exports.WALLET_LOG_TYPE = {
    RECHARGE: 1,
    WATER_PAY: 2,
};


/***/ }),
/* 82 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
    return function (target, key) { decorator(target, key, paramIndex); }
};
var _a;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.RechargeController = void 0;
const common_1 = __webpack_require__(3);
const recharge_service_1 = __webpack_require__(79);
const response_util_1 = __webpack_require__(56);
const constant_1 = __webpack_require__(55);
let RechargeController = class RechargeController {
    constructor(service) {
        this.service = service;
    }
    async options() {
        const options = await this.service.options();
        return response_util_1.ResponseUtilService.successRes(options);
    }
    async pay(id, req) {
        if (id < 1)
            return;
        const res = await this.service.recharge(id, req[constant_1.ReqAttrs.USER_ID], req[constant_1.ReqAttrs.CLIENT_SOURCE], req[constant_1.ReqAttrs.IS_WX]);
        return res == null ? response_util_1.ResponseUtilService.failRes() : response_util_1.ResponseUtilService.successRes(res);
    }
    async notify(id, client, data, res) {
        if (isNaN(id) || id <= 0) {
            res.status(common_1.HttpStatus.OK).send();
        }
        try {
            if (client == 'wx') {
                if (data.event_type == 'TRANSACTION.SUCCESS') {
                    const r = await this.service.notify(id, data.resource, true);
                    console.log(r);
                    if (r) {
                        res.status(common_1.HttpStatus.OK).send();
                    }
                    else {
                        res.status(common_1.HttpStatus.NOT_IMPLEMENTED).send({ code: 'FAIL', message: "失败" });
                    }
                }
            }
            else {
            }
            return;
        }
        catch (error) {
        }
        res.status(common_1.HttpStatus.NOT_IMPLEMENTED).send({ code: 'FAIL', message: "失败" });
    }
};
exports.RechargeController = RechargeController;
__decorate([
    (0, common_1.Get)('options'),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", []),
    __metadata("design:returntype", Promise)
], RechargeController.prototype, "options", null);
__decorate([
    (0, common_1.Post)('pay'),
    __param(0, (0, common_1.Body)('id', common_1.ParseIntPipe)),
    __param(1, (0, common_1.Req)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Number, Object]),
    __metadata("design:returntype", Promise)
], RechargeController.prototype, "pay", null);
__decorate([
    (0, common_1.Post)('notify/:client/:id'),
    __param(0, (0, common_1.Param)('id', common_1.ParseIntPipe)),
    __param(1, (0, common_1.Param)('client')),
    __param(2, (0, common_1.Body)()),
    __param(3, (0, common_1.Res)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Number, String, Object, Object]),
    __metadata("design:returntype", Promise)
], RechargeController.prototype, "notify", null);
exports.RechargeController = RechargeController = __decorate([
    (0, common_1.Controller)('recharge'),
    __metadata("design:paramtypes", [typeof (_a = typeof recharge_service_1.RechargeService !== "undefined" && recharge_service_1.RechargeService) === "function" ? _a : Object])
], RechargeController);


/***/ }),
/* 83 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var _a, _b;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.AuthGuard = void 0;
const configure_1 = __webpack_require__(29);
const jwt_verify_1 = __webpack_require__(69);
const common_1 = __webpack_require__(3);
const constant_1 = __webpack_require__(55);
const USER_SOURCE_1 = __webpack_require__(68);
let AuthGuard = class AuthGuard {
    async canActivate(context) {
        let request = context.switchToHttp().getRequest();
        const route = request.route;
        let path = route.path;
        const routePrefix = this.config.get('apiPrefix');
        if (routePrefix != undefined && routePrefix.length > 0) {
            path = path.substring(routePrefix.length + 1);
        }
        const token = request.headers.authorization;
        if (token) {
            const payload = this.jwt.verify(token);
            if (!payload)
                return false;
            request[constant_1.ReqAttrs.USER_ID] = payload.key;
        }
        if (request.headers['client-type']) {
            request[constant_1.ReqAttrs.IS_WX] = request.headers['client-type'] == 'wx';
            request[constant_1.ReqAttrs.IS_ALI] = request.headers['client-type'] == 'ali';
            request[constant_1.ReqAttrs.CLIENT_SOURCE] = request[constant_1.ReqAttrs.IS_WX] ? USER_SOURCE_1.USER_SOURCE.WX : USER_SOURCE_1.USER_SOURCE.ALI;
        }
        return true;
    }
};
exports.AuthGuard = AuthGuard;
__decorate([
    (0, common_1.Inject)(),
    __metadata("design:type", typeof (_a = typeof configure_1.ConfigureService !== "undefined" && configure_1.ConfigureService) === "function" ? _a : Object)
], AuthGuard.prototype, "config", void 0);
__decorate([
    (0, common_1.Inject)(),
    __metadata("design:type", typeof (_b = typeof jwt_verify_1.JwtVerifyService !== "undefined" && jwt_verify_1.JwtVerifyService) === "function" ? _b : Object)
], AuthGuard.prototype, "jwt", void 0);
exports.AuthGuard = AuthGuard = __decorate([
    (0, common_1.Injectable)()
], AuthGuard);


/***/ }),
/* 84 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.DeviceModule = void 0;
const common_1 = __webpack_require__(3);
const device_service_1 = __webpack_require__(85);
const device_controller_1 = __webpack_require__(97);
let DeviceModule = class DeviceModule {
};
exports.DeviceModule = DeviceModule;
exports.DeviceModule = DeviceModule = __decorate([
    (0, common_1.Module)({
        providers: [device_service_1.DeviceService],
        controllers: [device_controller_1.DeviceController],
        exports: [device_service_1.DeviceService]
    })
], DeviceModule);


/***/ }),
/* 85 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var _a, _b, _c, _d;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.DeviceService = void 0;
const common_1 = __webpack_require__(3);
const db_service_1 = __webpack_require__(7);
const cache_1 = __webpack_require__(46);
const work_exception_1 = __webpack_require__(86);
const typeorm_1 = __webpack_require__(10);
const DEVICE_TYPE_1 = __webpack_require__(87);
const alicloud_1 = __webpack_require__(88);
const configure_1 = __webpack_require__(29);
const DEVICE_CTR_RESULT_1 = __webpack_require__(95);
const DEVICE_CTR_ORDER_1 = __webpack_require__(96);
let DeviceService = class DeviceService {
    constructor(db, cache, alicloud, config) {
        this.db = db;
        this.cache = cache;
        this.alicloud = alicloud;
        this.config = config;
        this.aliToDeviceTopicReg = config.get('ALI_TO_DEVICE_TOPIC_REG');
    }
    async deviceOfUser(userId) {
        const deviceList = await this.db.device.find({ userId }, { id: true, deviceTypeId: true, connectStatus: true });
        const deviceTypeIds = [];
        deviceList.forEach(item => {
            if (!deviceTypeIds.includes(item.deviceTypeId)) {
                deviceTypeIds.push(item.deviceTypeId);
            }
        });
        const deviceTypes = await this.db.deviceType.find({ id: (0, typeorm_1.In)(deviceTypeIds) }, { id: true, name: true, code: true });
        deviceList.forEach(item => {
            const deviceType = deviceTypes.find(t => t.id == item.deviceTypeId);
            if (deviceType) {
                item.deviceType = deviceType;
            }
        });
        return deviceList;
    }
    async bindDevice(deviceId, userId) {
        const device = await this.db.device.findOne({ id: deviceId }, { userId: true, id: true, deviceTypeId: true });
        if (!device)
            return false;
        if (device.userId != 0)
            throw new work_exception_1.default('设备已被绑定');
        let lockKey = 'binddevice.' + deviceId;
        const lock = await this.cache.set(lockKey, '', 10, 'NX');
        if (!lock)
            return false;
        const deviceType = await this.db.deviceType.findOne({ id: device.deviceTypeId }, { code: true });
        if (deviceType.code == DEVICE_TYPE_1.DEVICE_TYPE.water) {
            const r = await this.db.device.isExistsByWhere({ userId, deviceTypeId: device.deviceTypeId });
            if (r)
                throw new work_exception_1.default('只能有一台水机');
        }
        const r = await this.db.device.update({ id: deviceId }, { userId: userId });
        this.cache.del(lockKey);
        return r > 0;
    }
    async unbindDevice(deviceId, userId) {
        const device = await this.db.device.findOne({ id: deviceId }, { userId: true, id: true });
        if (!device)
            return false;
        if (device.userId != userId)
            return true;
        const r = await this.db.device.update({ id: deviceId }, { userId: 0 });
        return r > 0;
    }
    async startDevice(deviceId, userId, param) {
        const device = await this.db.device.findOne({ id: deviceId }, { userId: true, id: true, deviceTypeId: true });
        if (!device || device.userId != userId)
            return false;
        const deviceType = await this.db.deviceType.findOne({ id: device.deviceTypeId }, { aliProduct: true });
        if (!deviceType)
            return false;
        const r = await this.pub(deviceId, deviceType.aliProduct, { "v": "ss_1", "goal": "1-1", "port": "1-1", "childPort": "", "cmd": DEVICE_CTR_ORDER_1.DEVICE_CTR_ORDER.SET_START_DEVICE, "param": param });
        if (r.success) {
            this.cache.set(DEVICE_CTR_ORDER_1.DEVICE_CTR_ORDER.SET_START_DEVICE + ':' + deviceId, DEVICE_CTR_RESULT_1.DEVICE_CTR_RESULT.WAIT, 10);
            return true;
        }
        return false;
    }
    async startDeviceRes(deviceId) {
        return this.cache.get(DEVICE_CTR_ORDER_1.DEVICE_CTR_ORDER.SET_START_DEVICE + ':' + deviceId);
    }
    async startClean(deviceId, userId, param) {
        const device = await this.db.device.findOne({ id: deviceId }, { userId: true, id: true, deviceTypeId: true });
        if (!device || device.userId != userId)
            return false;
        const deviceType = await this.db.deviceType.findOne({ id: device.deviceTypeId }, { aliProduct: true });
        if (!deviceType)
            return false;
        let id = 0;
        const msg = { "v": "ss_1", "goal": "1-1", "port": "1-1", "childPort": "", "cmd": DEVICE_CTR_ORDER_1.DEVICE_CTR_ORDER.SET_CLEAN_DEVICE, "param": param };
        if (param == '1') {
            const r = await this.db.cleanRecord.insert({
                userId,
                deviceId,
                status: DEVICE_CTR_RESULT_1.DEVICE_CTR_RESULT.WAIT,
                createTime: Math.floor(Date.now() / 1000)
            });
            if (r != null && r.affectedRows > 0) {
                id = r.rows[0][this.db.cleanRecord.primaryKey];
                msg.msgId = String(id);
            }
        }
        const r = await this.pub(deviceId, deviceType.aliProduct, msg);
        if (r.success) {
            this.cache.set(DEVICE_CTR_ORDER_1.DEVICE_CTR_ORDER.SET_CLEAN_DEVICE + ':' + deviceId, DEVICE_CTR_RESULT_1.DEVICE_CTR_RESULT.WAIT, 10);
            return true;
        }
        if (param == '1') {
            this.db.cleanRecord.update({ id: id }, { status: DEVICE_CTR_RESULT_1.DEVICE_CTR_RESULT.FAIL });
        }
        return false;
    }
    async cleanRes(deviceId) {
        return this.cache.get(DEVICE_CTR_ORDER_1.DEVICE_CTR_ORDER.SET_CLEAN_DEVICE + ':' + deviceId);
    }
    async cleanRecordPage(query, userId) {
        let where = { userId };
        const lastId = query.lastKey || 0;
        const pageSize = query.pageSize || 20;
        if (lastId > 0) {
            where.id = (0, typeorm_1.LessThan)(lastId);
        }
        let rows = await this.db.cleanRecord.getRepository().find({
            where,
            skip: 0,
            take: pageSize,
            order: { id: 'DESC' }
        });
        return rows;
    }
    async setMaxWaterFlow(deviceId, userId) {
        const device = await this.db.device.findOne({ id: deviceId }, { userId: true, id: true, deviceTypeId: true });
        if (!device || device.userId != userId)
            return false;
        const deviceType = await this.db.deviceType.findOne({ id: device.deviceTypeId }, { aliProduct: true });
        if (!deviceType)
            return false;
        const user = await this.db.user.findOne({ id: userId }, { amount: true, rewardAmount: true });
        const flow = Math.floor((user.amount + user.rewardAmount) / 0.1 * 1000);
        const msg = {
            "v": "ss_1",
            "cmd": DEVICE_CTR_ORDER_1.DEVICE_CTR_ORDER.SET_MAX_WATER_FLOW,
            "goal": "1-1",
            "port": "1-1",
            "param": String(flow),
            "childPort": "",
        };
        const r = await this.pub(deviceId, deviceType.aliProduct, msg);
        if (r.success) {
            this.cache.set(DEVICE_CTR_ORDER_1.DEVICE_CTR_ORDER.SET_MAX_WATER_FLOW + ':' + deviceId, DEVICE_CTR_RESULT_1.DEVICE_CTR_RESULT.WAIT, 10);
            return true;
        }
        return false;
    }
    async setMaxFlowRes(deviceId) {
        return this.cache.get(DEVICE_CTR_ORDER_1.DEVICE_CTR_ORDER.SET_MAX_WATER_FLOW + ':' + deviceId);
    }
    async pub(deviceId, productKey, msg) {
        const deviceName = String(deviceId);
        msg.dCore = deviceName;
        return this.alicloud.pub(productKey, this.aliToDeviceTopicReg.replace(/\?/, productKey).replace(/\?/, deviceName), deviceName, msg);
    }
};
exports.DeviceService = DeviceService;
exports.DeviceService = DeviceService = __decorate([
    (0, common_1.Injectable)(),
    __metadata("design:paramtypes", [typeof (_a = typeof db_service_1.DbService !== "undefined" && db_service_1.DbService) === "function" ? _a : Object, typeof (_b = typeof cache_1.CacheService !== "undefined" && cache_1.CacheService) === "function" ? _b : Object, typeof (_c = typeof alicloud_1.AlicloudService !== "undefined" && alicloud_1.AlicloudService) === "function" ? _c : Object, typeof (_d = typeof configure_1.ConfigureService !== "undefined" && configure_1.ConfigureService) === "function" ? _d : Object])
], DeviceService);


/***/ }),
/* 86 */
/***/ ((__unused_webpack_module, exports) => {


Object.defineProperty(exports, "__esModule", ({ value: true }));
class WorkException extends Error {
    constructor(message, code = 0) {
        super(message);
        this.isWork = true;
        this.code = code;
        this.name = this.constructor.name;
        Error.captureStackTrace(this, this.constructor);
    }
}
exports["default"] = WorkException;


/***/ }),
/* 87 */
/***/ ((__unused_webpack_module, exports) => {


Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.DEVICE_TYPE = void 0;
exports.DEVICE_TYPE = {
    water: 'water'
};


/***/ }),
/* 88 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
    for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
__exportStar(__webpack_require__(89), exports);
__exportStar(__webpack_require__(90), exports);


/***/ }),
/* 89 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var AlicloudModule_1;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.AlicloudModule = void 0;
const common_1 = __webpack_require__(3);
const alicloud_service_1 = __webpack_require__(90);
let AlicloudModule = AlicloudModule_1 = class AlicloudModule {
    static forRootAsync(options) {
        const providers = [
            {
                provide: 'ALI_MODULE_OPTIONS',
                useFactory: options.useFactory,
                inject: options.inject || [],
            },
            alicloud_service_1.AlicloudService,
        ];
        return {
            module: AlicloudModule_1,
            providers: providers,
            exports: [alicloud_service_1.AlicloudService],
        };
    }
};
exports.AlicloudModule = AlicloudModule;
exports.AlicloudModule = AlicloudModule = AlicloudModule_1 = __decorate([
    (0, common_1.Global)()
], AlicloudModule);


/***/ }),
/* 90 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
    return function (target, key) { decorator(target, key, paramIndex); }
};
var _a;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.AlicloudService = void 0;
const common_1 = __webpack_require__(3);
const iot20180120_1 = __webpack_require__(91), $Iot = iot20180120_1;
const $OpenApi = __webpack_require__(92);
const IotCofig_1 = __webpack_require__(93);
const node_crypto_1 = __webpack_require__(94);
let AlicloudService = class AlicloudService {
    constructor(options) {
        this.options = options;
        this.iotClient();
    }
    iotClient() {
        let config = new $OpenApi.Config({
            accessKeyId: this.options.accessKeyId,
            accessKeySecret: this.options.accessKeySecret,
            regionId: this.options.regionId
        });
        this.client = new iot20180120_1.default(config);
    }
    async registerDevice(productKey, deviceName) {
        try {
            const req = new $Iot.RegisterDeviceRequest({
                productKey,
                deviceName: deviceName,
            });
            if (this.options.iotInstanceId) {
                req.iotInstanceId = this.options.iotInstanceId;
            }
            const r = await this.client.registerDevice(req);
            if (r.statusCode == 200)
                return r.body;
        }
        catch (error) {
        }
        return null;
    }
    async queryDeviceInfo(productKey, deviceName) {
        try {
            const req = new $Iot.QueryDeviceInfoRequest({
                productKey,
                deviceName: deviceName,
            });
            if (this.options.iotInstanceId) {
                req.iotInstanceId = this.options.iotInstanceId;
            }
            const r = await this.client.queryDeviceInfo(req);
            if (r.statusCode == 200)
                return r.body;
        }
        catch (error) {
        }
        return null;
    }
    async batchQueryDeviceDetail(productKey, deviceNames) {
        try {
            const req = new $Iot.BatchQueryDeviceDetailRequest({
                deviceName: deviceNames,
                productKey: productKey,
            });
            if (this.options.iotInstanceId) {
                req.iotInstanceId = this.options.iotInstanceId;
            }
            const r = await this.client.batchQueryDeviceDetail(req);
            if (r.statusCode == 200)
                return r.body;
        }
        catch (error) {
        }
        return null;
    }
    async batchCheckDeviceNames(productKey, deviceNames) {
        try {
            const req = new $Iot.BatchCheckDeviceNamesRequest({
                productKey,
                deviceName: deviceNames,
            });
            if (this.options.iotInstanceId) {
                req.iotInstanceId = this.options.iotInstanceId;
            }
            const r = await this.client.batchCheckDeviceNames(req);
            if (r.statusCode == 200)
                return r.body;
        }
        catch (error) {
        }
        return null;
    }
    async batchRegisterDeviceWithApplyId(productKey, applyId) {
        try {
            const req = new $Iot.BatchRegisterDeviceWithApplyIdRequest({
                productKey,
                applyId: applyId,
            });
            if (this.options.iotInstanceId) {
                req.iotInstanceId = this.options.iotInstanceId;
            }
            const r = await this.client.batchRegisterDeviceWithApplyId(req);
            if (r.statusCode == 200)
                return r.body;
        }
        catch (error) {
        }
        return null;
    }
    async deleteDevice(productKey, deviceName) {
        try {
            const req = new $Iot.DeleteDeviceRequest({
                productKey: productKey,
                deviceName: deviceName
            });
            if (this.options.iotInstanceId) {
                req.iotInstanceId = this.options.iotInstanceId;
            }
            const r = await this.client.deleteDevice(req);
            if (r.statusCode == 200)
                return r.body;
        }
        catch (error) {
        }
        return null;
    }
    async batchPub(productKey, topicTemplateName, deviceNames, messageContent, options = {}) {
        try {
            const req = new $Iot.BatchPubRequest({
                productKey: productKey,
                deviceName: deviceNames,
                topicTemplateName: topicTemplateName,
                messageContent: Buffer.from(JSON.stringify(messageContent)).toString('base64'),
                ...options
            });
            if (this.options.iotInstanceId) {
                req.iotInstanceId = this.options.iotInstanceId;
            }
            const r = await this.client.batchPub(req);
            if (r.statusCode == 200)
                return r.body;
        }
        catch (error) {
        }
        return null;
    }
    async pub(productKey, topicFullName, deviceName, messageContent, options = {}) {
        try {
            console.log(messageContent);
            if (!messageContent.msgId) {
                messageContent.msgId = (0, node_crypto_1.createHash)('md5').update(Date.now() + deviceName).digest('hex').toLowerCase().substring(0, 16);
            }
            else {
                if (messageContent.msgId.length < 16) {
                    messageContent.msgId = messageContent.msgId.padStart(16, '0');
                }
            }
            const req = new $Iot.PubRequest({
                productKey: productKey,
                deviceName: deviceName,
                topicFullName: topicFullName,
                messageContent: Buffer.from(JSON.stringify(messageContent)).toString('base64'),
                ...options
            });
            if (this.options.iotInstanceId) {
                req.iotInstanceId = this.options.iotInstanceId;
            }
            const r = await this.client.pub(req);
            if (r.statusCode == 200)
                return r.body;
        }
        catch (error) {
        }
        return null;
    }
};
exports.AlicloudService = AlicloudService;
exports.AlicloudService = AlicloudService = __decorate([
    (0, common_1.Injectable)(),
    __param(0, (0, common_1.Inject)('ALI_MODULE_OPTIONS')),
    __metadata("design:paramtypes", [typeof (_a = typeof IotCofig_1.IotConfig !== "undefined" && IotCofig_1.IotConfig) === "function" ? _a : Object])
], AlicloudService);


/***/ }),
/* 91 */
/***/ ((module) => {

module.exports = require("@alicloud/iot20180120");

/***/ }),
/* 92 */
/***/ ((module) => {

module.exports = require("@alicloud/openapi-client");

/***/ }),
/* 93 */
/***/ ((__unused_webpack_module, exports) => {


Object.defineProperty(exports, "__esModule", ({ value: true }));


/***/ }),
/* 94 */
/***/ ((module) => {

module.exports = require("node:crypto");

/***/ }),
/* 95 */
/***/ ((__unused_webpack_module, exports) => {


Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.DEVICE_CTR_RESULT = void 0;
exports.DEVICE_CTR_RESULT = {
    WAIT: 0,
    SUCCESS: 1,
    FAIL: 2
};


/***/ }),
/* 96 */
/***/ ((__unused_webpack_module, exports) => {


Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.DEVICE_CTR_ORDER = void 0;
exports.DEVICE_CTR_ORDER = {
    SET_START_DEVICE: 'setStartStu',
    SET_CLEAN_DEVICE: 'setClearStu',
    SET_MAX_WATER_FLOW: 'setMaxWaterFlow',
    SET_CHECK_STEP: 'setCheckStep'
};


/***/ }),
/* 97 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
    return function (target, key) { decorator(target, key, paramIndex); }
};
var _a, _b;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.DeviceController = void 0;
const common_1 = __webpack_require__(3);
const device_service_1 = __webpack_require__(85);
const constant_1 = __webpack_require__(55);
const response_util_1 = __webpack_require__(56);
let DeviceController = class DeviceController {
    constructor(service) {
        this.service = service;
    }
    async list(req) {
        const list = await this.service.deviceOfUser(req[constant_1.ReqAttrs.USER_ID]);
        return response_util_1.ResponseUtilService.successRes(list);
    }
    async bind(id, req) {
        try {
            const r = await this.service.bindDevice(id, req[constant_1.ReqAttrs.USER_ID]);
            return r ? response_util_1.ResponseUtilService.successRes() : response_util_1.ResponseUtilService.failRes();
        }
        catch (error) {
            return response_util_1.ResponseUtilService.failRes(error.message);
        }
    }
    async unbind(id, req) {
        try {
            const r = await this.service.unbindDevice(id, req[constant_1.ReqAttrs.USER_ID]);
            return r ? response_util_1.ResponseUtilService.successRes() : response_util_1.ResponseUtilService.failRes();
        }
        catch (error) {
            return response_util_1.ResponseUtilService.failRes(error.message);
        }
    }
    async startDevice(id, req) {
        try {
            const r = await this.service.startDevice(id, req[constant_1.ReqAttrs.USER_ID], '1');
            return r ? response_util_1.ResponseUtilService.successRes() : response_util_1.ResponseUtilService.failRes();
        }
        catch (error) {
            return response_util_1.ResponseUtilService.failRes(error.message);
        }
    }
    async stopDevice(id, req) {
        try {
            const r = await this.service.startDevice(id, req[constant_1.ReqAttrs.USER_ID], '0');
            return r ? response_util_1.ResponseUtilService.successRes() : response_util_1.ResponseUtilService.failRes();
        }
        catch (error) {
            return response_util_1.ResponseUtilService.failRes(error.message);
        }
    }
    async setRes(id) {
        const res = await this.service.startDeviceRes(id);
        return response_util_1.ResponseUtilService.successRes(res);
    }
    async startClean(id, req) {
        try {
            const r = await this.service.startClean(id, req[constant_1.ReqAttrs.USER_ID], '1');
            return r ? response_util_1.ResponseUtilService.successRes() : response_util_1.ResponseUtilService.failRes();
        }
        catch (error) {
            return response_util_1.ResponseUtilService.failRes(error.message);
        }
    }
    async stopClean(id, req) {
        try {
            const r = await this.service.startClean(id, req[constant_1.ReqAttrs.USER_ID], '0');
            return r ? response_util_1.ResponseUtilService.successRes() : response_util_1.ResponseUtilService.failRes();
        }
        catch (error) {
            return response_util_1.ResponseUtilService.failRes(error.message);
        }
    }
    async cleanRes(id) {
        const res = await this.service.cleanRes(id);
        return response_util_1.ResponseUtilService.successRes(res);
    }
    async page(dto, { userId }) {
        let rows = await this.service.cleanRecordPage(dto, userId);
        return response_util_1.ResponseUtilService.successRes(rows);
    }
    async setMaxFlow(id, req) {
        try {
            const r = await this.service.setMaxWaterFlow(id, req[constant_1.ReqAttrs.USER_ID]);
            return r ? response_util_1.ResponseUtilService.successRes() : response_util_1.ResponseUtilService.failRes();
        }
        catch (error) {
            return response_util_1.ResponseUtilService.failRes(error.message);
        }
    }
    async setMaxFlowRes(id) {
        const res = await this.service.setMaxFlowRes(id);
        return response_util_1.ResponseUtilService.successRes(res);
    }
};
exports.DeviceController = DeviceController;
__decorate([
    (0, common_1.Get)('list'),
    __param(0, (0, common_1.Req)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object]),
    __metadata("design:returntype", Promise)
], DeviceController.prototype, "list", null);
__decorate([
    (0, common_1.Post)('bind'),
    __param(0, (0, common_1.Body)('id', common_1.ParseIntPipe)),
    __param(1, (0, common_1.Req)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Number, Object]),
    __metadata("design:returntype", Promise)
], DeviceController.prototype, "bind", null);
__decorate([
    (0, common_1.Post)('unbind'),
    __param(0, (0, common_1.Body)('id', common_1.ParseIntPipe)),
    __param(1, (0, common_1.Req)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Number, Object]),
    __metadata("design:returntype", Promise)
], DeviceController.prototype, "unbind", null);
__decorate([
    (0, common_1.Post)('start'),
    __param(0, (0, common_1.Body)('id', common_1.ParseIntPipe)),
    __param(1, (0, common_1.Req)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Number, Object]),
    __metadata("design:returntype", Promise)
], DeviceController.prototype, "startDevice", null);
__decorate([
    (0, common_1.Post)('stop'),
    __param(0, (0, common_1.Body)('id', common_1.ParseIntPipe)),
    __param(1, (0, common_1.Req)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Number, Object]),
    __metadata("design:returntype", Promise)
], DeviceController.prototype, "stopDevice", null);
__decorate([
    (0, common_1.Get)('setRes/:id'),
    __param(0, (0, common_1.Param)('id')),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String]),
    __metadata("design:returntype", Promise)
], DeviceController.prototype, "setRes", null);
__decorate([
    (0, common_1.Post)('startClean'),
    __param(0, (0, common_1.Body)('id', common_1.ParseIntPipe)),
    __param(1, (0, common_1.Req)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Number, Object]),
    __metadata("design:returntype", Promise)
], DeviceController.prototype, "startClean", null);
__decorate([
    (0, common_1.Post)('stopClean'),
    __param(0, (0, common_1.Body)('id', common_1.ParseIntPipe)),
    __param(1, (0, common_1.Req)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Number, Object]),
    __metadata("design:returntype", Promise)
], DeviceController.prototype, "stopClean", null);
__decorate([
    (0, common_1.Get)('cleanRes/:id'),
    __param(0, (0, common_1.Param)('id')),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String]),
    __metadata("design:returntype", Promise)
], DeviceController.prototype, "cleanRes", null);
__decorate([
    (0, common_1.Post)('cleanRecord/page'),
    __param(0, (0, common_1.Body)()),
    __param(1, (0, common_1.Req)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [typeof (_b = typeof Pagination !== "undefined" && Pagination) === "function" ? _b : Object, Object]),
    __metadata("design:returntype", Promise)
], DeviceController.prototype, "page", null);
__decorate([
    (0, common_1.Post)('setMaxFlow'),
    __param(0, (0, common_1.Body)('id', common_1.ParseIntPipe)),
    __param(1, (0, common_1.Req)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Number, Object]),
    __metadata("design:returntype", Promise)
], DeviceController.prototype, "setMaxFlow", null);
__decorate([
    (0, common_1.Get)('setMaxFlowRes/:id'),
    __param(0, (0, common_1.Param)('id')),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String]),
    __metadata("design:returntype", Promise)
], DeviceController.prototype, "setMaxFlowRes", null);
exports.DeviceController = DeviceController = __decorate([
    (0, common_1.Controller)('device'),
    __metadata("design:paramtypes", [typeof (_a = typeof device_service_1.DeviceService !== "undefined" && device_service_1.DeviceService) === "function" ? _a : Object])
], DeviceController);


/***/ }),
/* 98 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.TestModule = void 0;
const common_1 = __webpack_require__(3);
const test_service_1 = __webpack_require__(99);
const test_controller_1 = __webpack_require__(100);
const device_module_1 = __webpack_require__(84);
let TestModule = class TestModule {
};
exports.TestModule = TestModule;
exports.TestModule = TestModule = __decorate([
    (0, common_1.Module)({
        imports: [device_module_1.DeviceModule],
        providers: [test_service_1.TestService],
        controllers: [test_controller_1.TestController]
    })
], TestModule);


/***/ }),
/* 99 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var _a, _b, _c, _d;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.TestService = void 0;
const common_1 = __webpack_require__(3);
const db_service_1 = __webpack_require__(7);
const cache_1 = __webpack_require__(46);
const alicloud_1 = __webpack_require__(88);
const device_service_1 = __webpack_require__(85);
const DEVICE_CTR_ORDER_1 = __webpack_require__(96);
let TestService = class TestService {
    constructor(db, cache, alicloud, deivce) {
        this.db = db;
        this.cache = cache;
        this.alicloud = alicloud;
        this.deivce = deivce;
    }
    async test(deviceId, userId) {
        const key = 'test.' + deviceId;
        const had = await this.cache.get(key);
        if (had != null)
            return null;
        let lockKey = 'test.lock.' + deviceId;
        const lock = await this.cache.set(lockKey, '', 10, 'NX');
        if (!lock)
            return null;
        const device = await this.db.device.findOne({ id: deviceId }, { userId: true, deviceTypeId: true, aliSecret: true });
        if (!device || device.userId != userId)
            return null;
        const deviceType = await this.db.deviceType.findOne({ id: device.deviceTypeId }, { aliProduct: true });
        if (!deviceType)
            return null;
        const r = await this.db.waterTest.insert({
            userId,
            deviceId,
            createTime: Math.floor(Date.now() / 1000),
        });
        if (r != null && r.affectedRows > 0) {
            this.cache.set(key, r.rows[0].id);
            this.deivce.pub(deviceId, deviceType.aliProduct, {
                v: "ss_1",
                goal: "0",
                cmd: DEVICE_CTR_ORDER_1.DEVICE_CTR_ORDER.SET_CHECK_STEP,
                param: "1",
                port: '0',
                childPort: "",
                msgId: String(r.rows[0].id)
            });
        }
    }
};
exports.TestService = TestService;
exports.TestService = TestService = __decorate([
    (0, common_1.Injectable)(),
    __metadata("design:paramtypes", [typeof (_a = typeof db_service_1.DbService !== "undefined" && db_service_1.DbService) === "function" ? _a : Object, typeof (_b = typeof cache_1.CacheService !== "undefined" && cache_1.CacheService) === "function" ? _b : Object, typeof (_c = typeof alicloud_1.AlicloudService !== "undefined" && alicloud_1.AlicloudService) === "function" ? _c : Object, typeof (_d = typeof device_service_1.DeviceService !== "undefined" && device_service_1.DeviceService) === "function" ? _d : Object])
], TestService);


/***/ }),
/* 100 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.TestController = void 0;
const common_1 = __webpack_require__(3);
let TestController = class TestController {
};
exports.TestController = TestController;
exports.TestController = TestController = __decorate([
    (0, common_1.Controller)('test')
], TestController);


/***/ }),
/* 101 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.WaterBillsModule = void 0;
const common_1 = __webpack_require__(3);
const water_bills_service_1 = __webpack_require__(102);
const water_bills_controller_1 = __webpack_require__(103);
let WaterBillsModule = class WaterBillsModule {
};
exports.WaterBillsModule = WaterBillsModule;
exports.WaterBillsModule = WaterBillsModule = __decorate([
    (0, common_1.Module)({
        providers: [water_bills_service_1.WaterBillsService],
        controllers: [water_bills_controller_1.WaterBillsController]
    })
], WaterBillsModule);


/***/ }),
/* 102 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var _a;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.WaterBillsService = void 0;
const common_1 = __webpack_require__(3);
const db_service_1 = __webpack_require__(7);
const typeorm_1 = __webpack_require__(10);
let WaterBillsService = class WaterBillsService {
    constructor(db) {
        this.db = db;
    }
    async page(query, userId) {
        let where = { userId };
        const lastId = query.lastKey || 0;
        const pageSize = query.pageSize || 20;
        if (lastId > 0) {
            where.id = (0, typeorm_1.LessThan)(lastId);
        }
        let rows = await this.db.waterBills.getRepository().find({
            where,
            skip: 0,
            take: pageSize,
            order: { id: 'DESC' }
        });
        return rows;
    }
};
exports.WaterBillsService = WaterBillsService;
exports.WaterBillsService = WaterBillsService = __decorate([
    (0, common_1.Injectable)(),
    __metadata("design:paramtypes", [typeof (_a = typeof db_service_1.DbService !== "undefined" && db_service_1.DbService) === "function" ? _a : Object])
], WaterBillsService);


/***/ }),
/* 103 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
    return function (target, key) { decorator(target, key, paramIndex); }
};
var _a, _b;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.WaterBillsController = void 0;
const common_1 = __webpack_require__(3);
const water_bills_service_1 = __webpack_require__(102);
const response_util_1 = __webpack_require__(56);
let WaterBillsController = class WaterBillsController {
    constructor(service) {
        this.service = service;
    }
    async page(dto, { userId }) {
        let rows = await this.service.page(dto, userId);
        return response_util_1.ResponseUtilService.successRes(rows);
    }
};
exports.WaterBillsController = WaterBillsController;
__decorate([
    (0, common_1.Post)('page'),
    __param(0, (0, common_1.Body)()),
    __param(1, (0, common_1.Req)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [typeof (_b = typeof Pagination !== "undefined" && Pagination) === "function" ? _b : Object, Object]),
    __metadata("design:returntype", Promise)
], WaterBillsController.prototype, "page", null);
exports.WaterBillsController = WaterBillsController = __decorate([
    (0, common_1.Controller)('waterBills'),
    __metadata("design:paramtypes", [typeof (_a = typeof water_bills_service_1.WaterBillsService !== "undefined" && water_bills_service_1.WaterBillsService) === "function" ? _a : Object])
], WaterBillsController);


/***/ }),
/* 104 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.WaterTestModule = void 0;
const common_1 = __webpack_require__(3);
const water_test_service_1 = __webpack_require__(105);
const water_test_controller_1 = __webpack_require__(106);
const device_module_1 = __webpack_require__(84);
let WaterTestModule = class WaterTestModule {
};
exports.WaterTestModule = WaterTestModule;
exports.WaterTestModule = WaterTestModule = __decorate([
    (0, common_1.Module)({
        imports: [device_module_1.DeviceModule],
        providers: [water_test_service_1.WaterTestService],
        controllers: [water_test_controller_1.WaterTestController]
    })
], WaterTestModule);


/***/ }),
/* 105 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var _a, _b, _c, _d;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.WaterTestService = void 0;
const common_1 = __webpack_require__(3);
const db_service_1 = __webpack_require__(7);
const typeorm_1 = __webpack_require__(10);
const alicloud_1 = __webpack_require__(88);
const cache_1 = __webpack_require__(46);
const device_service_1 = __webpack_require__(85);
const DEVICE_CTR_ORDER_1 = __webpack_require__(96);
let WaterTestService = class WaterTestService {
    constructor(db, cache, alicloud, deivce) {
        this.db = db;
        this.cache = cache;
        this.alicloud = alicloud;
        this.deivce = deivce;
    }
    async test(deviceId, userId) {
        const key = 'test.' + deviceId;
        const had = await this.cache.get(key);
        let lockKey = 'test.lock.' + deviceId;
        const lock = await this.cache.set(lockKey, '', 10, 'NX');
        if (!lock)
            return null;
        const device = await this.db.device.findOne({ id: deviceId }, { userId: true, deviceTypeId: true, aliSecret: true });
        if (!device || device.userId != userId)
            return null;
        const deviceType = await this.db.deviceType.findOne({ id: device.deviceTypeId }, { aliProduct: true });
        if (!deviceType)
            return null;
        const r = await this.db.waterTest.insert({
            userId,
            deviceId,
            createTime: Math.floor(Date.now() / 1000),
        });
        console.log(r);
        if (r != null && r.affectedRows > 0) {
            this.cache.set(key, r.rows[0].id);
            const res = await this.deivce.pub(deviceId, deviceType.aliProduct, {
                "v": "ss_1",
                cmd: DEVICE_CTR_ORDER_1.DEVICE_CTR_ORDER.SET_CHECK_STEP,
                param: "1",
                port: '0',
                "goal": "0",
                childPort: "",
                msgId: String(r.rows[0].id),
            });
            console.log(res);
        }
    }
    async page(query, userId) {
        let where = { userId };
        const lastId = query.lastKey || 0;
        const pageSize = query.pageSize || 20;
        if (lastId > 0) {
            where.id = (0, typeorm_1.LessThan)(lastId);
        }
        let rows = await this.db.waterTest.getRepository().find({
            select: { id: true, deviceId: true, status: true, result: true, createTime: true, endTime: true },
            where,
            skip: 0,
            take: pageSize,
            order: { id: 'DESC' }
        });
        return rows;
    }
};
exports.WaterTestService = WaterTestService;
exports.WaterTestService = WaterTestService = __decorate([
    (0, common_1.Injectable)(),
    __metadata("design:paramtypes", [typeof (_a = typeof db_service_1.DbService !== "undefined" && db_service_1.DbService) === "function" ? _a : Object, typeof (_b = typeof cache_1.CacheService !== "undefined" && cache_1.CacheService) === "function" ? _b : Object, typeof (_c = typeof alicloud_1.AlicloudService !== "undefined" && alicloud_1.AlicloudService) === "function" ? _c : Object, typeof (_d = typeof device_service_1.DeviceService !== "undefined" && device_service_1.DeviceService) === "function" ? _d : Object])
], WaterTestService);


/***/ }),
/* 106 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
    return function (target, key) { decorator(target, key, paramIndex); }
};
var _a, _b;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.WaterTestController = void 0;
const common_1 = __webpack_require__(3);
const water_test_service_1 = __webpack_require__(105);
const response_util_1 = __webpack_require__(56);
const constant_1 = __webpack_require__(55);
let WaterTestController = class WaterTestController {
    constructor(service) {
        this.service = service;
    }
    async test(id, req) {
        let rows = await this.service.test(id, req[constant_1.ReqAttrs.USER_ID]);
        return response_util_1.ResponseUtilService.successRes(rows);
    }
    async page(dto, req) {
        let rows = await this.service.page(dto, req[constant_1.ReqAttrs.USER_ID]);
        return response_util_1.ResponseUtilService.successRes(rows);
    }
};
exports.WaterTestController = WaterTestController;
__decorate([
    (0, common_1.Post)('test'),
    __param(0, (0, common_1.Body)('id', common_1.ParseIntPipe)),
    __param(1, (0, common_1.Req)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Number, Object]),
    __metadata("design:returntype", Promise)
], WaterTestController.prototype, "test", null);
__decorate([
    (0, common_1.Post)('page'),
    __param(0, (0, common_1.Body)()),
    __param(1, (0, common_1.Req)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [typeof (_b = typeof Pagination !== "undefined" && Pagination) === "function" ? _b : Object, Object]),
    __metadata("design:returntype", Promise)
], WaterTestController.prototype, "page", null);
exports.WaterTestController = WaterTestController = __decorate([
    (0, common_1.Controller)('waterTest'),
    __metadata("design:paramtypes", [typeof (_a = typeof water_test_service_1.WaterTestService !== "undefined" && water_test_service_1.WaterTestService) === "function" ? _a : Object])
], WaterTestController);


/***/ })
/******/ 	]);
/************************************************************************/
/******/ 	// The module cache
/******/ 	var __webpack_module_cache__ = {};
/******/ 	
/******/ 	// The require function
/******/ 	function __webpack_require__(moduleId) {
/******/ 		// Check if module is in cache
/******/ 		var cachedModule = __webpack_module_cache__[moduleId];
/******/ 		if (cachedModule !== undefined) {
/******/ 			return cachedModule.exports;
/******/ 		}
/******/ 		// Create a new module (and put it into the cache)
/******/ 		var module = __webpack_module_cache__[moduleId] = {
/******/ 			// no module.id needed
/******/ 			// no module.loaded needed
/******/ 			exports: {}
/******/ 		};
/******/ 	
/******/ 		// Execute the module function
/******/ 		__webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/ 	
/******/ 		// Return the exports of the module
/******/ 		return module.exports;
/******/ 	}
/******/ 	
/************************************************************************/
var __webpack_exports__ = {};
// This entry needs to be wrapped in an IIFE because it needs to be isolated against other modules in the chunk.
(() => {
var exports = __webpack_exports__;

Object.defineProperty(exports, "__esModule", ({ value: true }));
const core_1 = __webpack_require__(1);
const user_client_module_1 = __webpack_require__(2);
const configure_1 = __webpack_require__(29);
async function bootstrap() {
    console.log('starting.....');
    const app = await core_1.NestFactory.create(user_client_module_1.UserClientModule);
    const configure = app.get(configure_1.ConfigureService);
    const apiPrefix = configure.get('API_PRE_FIX');
    const port = Number(configure.get('HTTP_PORT'));
    let url = 'http://localhost:' + port;
    if (apiPrefix != undefined && apiPrefix.length > 0) {
        url += ('/' + apiPrefix);
        app.setGlobalPrefix(apiPrefix);
    }
    await app.listen(port);
    console.log('url:' + url);
}
bootstrap();

})();

/******/ })()
;